|
 |
"Bald Eagle" <cre### [at] netscape net> wrote:
>
> Try using floor(). Or ceil. Or maybe POV-Ray does weird things and you
> need to test your value and then conditionally use one or the other.
>
FIXED for fractional values, by using floor:
---------
#macro SciNot (Num, Precision)
#if (Num = 0)
#local Result = "0\n"
#else
#local Exponent = int(floor(log(abs(Num))));
#local Significand = Num/pow(10, Exponent);
#local Result = concat (str(Significand, 0, Precision), "e", str(Exponent, 0,
0), "\n")
#end
#debug Result
#end
---------
Example:
#declare MY_VAL = -.00674;
// the macro:
SciNot (MY_VAL, 3)
returns -6.740e-3
-----------
BTW, this will also work:
#local Exponent = int(log(#if(Num < 1 & Num > -1) .1* #else #end abs(Num)));
Post a reply to this message
|
 |