// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Creation Date: October 12, 2016 // // Procedure Name: // texRoundOff // // Description: // General utility function that rounds a float number to a fixed amount // of decimal numbers. Also converts infinitesimal numbers into 0.0 // // Input Arguments // value - Float - Number to float // precision - Int - Amount of decimals // // Return Value: // Float - The rounded off number. // // Notes: // This script is part of the implementation of Nightshade UV Editor into // Autodesk Maya. This script is sourced by other scripts. Do not run it // directly. // // =========================================================================== global proc float texRoundOff(float $value, int $precision){ string $number = $value; // Check for scientific format if (`gmatch $number "*e*"`){ $value = 0.0; } return (trunc($value * `pow 10 $precision` + sign($value) * 0.5) / `pow 10 $precision`); }