Decimal point format operator as in C printf?
by Rob Segal · in Torque Game Builder · 07/18/2006 (10:17 pm) · 2 replies
Is there a format operator in torque script where I can cut the number of decimal points displayed on a floating point number like in C...
So the above example would print 2.34.
float x = 2.345345345345345;
printf("%.2f", x);So the above example would print 2.34.
Torque Owner Thomas Buscaglia
mFloatLength( val , numDecimals )
Purpose
Use the mFloatLength function to limit the number of decimal places in val to numDecimals.
Syntax
val - A floating-point value.
numDecimals - An integer between 0 and inf representing the number of decimal places to allow val to have.
Returns
Returns a floating-point value equivalent to a truncated version of val, where the new version has numDecimals decimal places.