POV-Ray : Newsgroups : povray.newusers : scientific notation : Re: scientific notation Server Time
3 Oct 2025 04:22:27 EDT (-0400)
  Re: scientific notation  
From: Bald Eagle
Date: 23 Sep 2025 13:05:00
Message: <web.68d2d291f4db7ec91398638025979125@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> Forget my clumsy string-code
> version; this one is certainly more compact and easy to grasp. It works with all
> float values, as far as I know from many tests. I have included the code itself
> and as a macro. The output is again as a #debug message.

Forget my crummy early-morning loop suggestion.  Just use int(log(abs(num)))

No idea what you're doing in your code,
but 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

- BW


Post a reply to this message

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