POV-Ray : Newsgroups : povray.newusers : scientific notation : Re: scientific notation Server Time
3 Oct 2025 04:17:26 EDT (-0400)
  Re: scientific notation  
From: Kenneth
Date: 23 Sep 2025 13:45:00
Message: <web.68d2dbc4f4db7ec9e83955656e066e29@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:
> try:
>
> #macro SciNot (Num, Precision)
> #if (Num = 0)
> #local Result = "0\n"
> #else
> #local Exponent = int(log(abs(Num)));
> #local Significand = Num/pow(10, Exponent);
> #local Result = concat (str(Significand, 0, Precision), " x 10^", str(Exponent,
> 0, 0), "\n")
> #end // end if
> #debug Result
> #end // end macro
>

(I changed your " x 10^" to "e" )

Yes, it works and is quite elegant, although it's a bit beyond my mental grasp
as to how. I haven't used logarithms since my college days, ha.

Although: For fractional values like .000794, it returns 0.794e-3. Shouldn't it
return 7.94e-4 instead?


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.