• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

World: r4wp

[#Red] Red language group

int-to-float causes a error. Or does it? I added some prints and 
inbetween steps
	genrand-real2: func [
		return: [float!] 
		/local result [float!] between [float!] intermediate [integer!]
	    intermediate: genrand-int32
	    print ["intermediate: " intermediate lf]
		;result: int-to-float genrand-int32
		between: int-to-float intermediate
        print ["between: " between lf]
		result: ((1.0 / 4294967296.0) * between) ;; divided by 2^32 
		return result

ON the second value the program errs:
intermediate: -1734706621
between: -1734706560
-0.40389284491539 intermediate: -1052231088

*** Runtime Error 9: float invalid operation
*** at: 00002033h

When I make my testprogram for user.reds tell me why int-to-float 
behaves like this:
intval: -1052231088
floval: int-to-float intval
print ["intval: " intval " lets floval become: " floval lf]
The output is not a runtime error:
intval: -1052231088 lets floval become: -1052231040

But the print line was not executed in my real program? I only have 
one user.reds file in my directory. Suggestions?