|
|
On 24/07/2023 20:27, Leroy wrote:
> I have pov3.7 on my winXP.
> While playing around with making music using POV. I made long rhythm strings
> and turn them into numbers and visa versa. Using random numbers to check things
> out, when negative random numbers show up. With NO negative numbers on the page.
> It's not a big deal in my case. But I wonder if this is a window thing, or a
> float thing in POV,and if anyone else came a cross this.
Window thing : no.
Float thing in POV : yes and no !
In fact, as is often the case, we come back to the
interpretation/implementation of the int() function
with binaries representation of floating point numbers
in 32 or 64 bits.
Try this piece of code :
#declare r = rand(S);
#debug concat("rand(S) = ",str(r,0,-1),"\n")
#declare Mv=r*Cv;
#debug concat("rand(S)*Cv = ",str(Mv,0,-1),"\n")
#declare Mv1 = int(Mv);
#debug concat("int(rand(S)*Cv) = ",str(Mv1,0,0),"\n")
#declare Mv2 = floor(Mv);
#debug concat("floor(rand(S)*Cv) = ",str(Mv2,0,0),"\n")
And the results are :
rand(S) = 0.501773
rand(S)*Cv = 551705517183.952148
int(rand(S)*Cv) = -2147483648
floor(rand(S)*Cv) = 551705517183
Have fun too with https://baseconvert.com/ieee-754-floating-point
--
Kurtz le pirate
Compagnie de la Banquise
Post a reply to this message
|
|