HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Long number weirdness

07-16-2007, 11:11 PM#1
grim001
Collapse JASS:
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    call BJDebugMsg(R2S(0.0174532925))
    call BJDebugMsg(R2S(0.017453292))
    call BJDebugMsg(R2S(1234567891))
    call BJDebugMsg(R2S(123456789))
endfunction

This prints
0.124
0.017
1234567808.00
123456784.00

Can someone explain to me why this happens? Does WC3 go crazy when you pass a certain number of digits?
07-17-2007, 02:53 AM#2
Naakaloh
There was a thread on this before I believe. I think it was something Anitarf discovered when working on a physics engine or something... Look up "Reals" "Physics engine" or something like that.


Edit: I think this is it...
http://www.wc3campaigns.net/showthread.php?t=84489
07-17-2007, 03:05 AM#3
PipeDream
Confirmed test.
1+2: Inexplicable, your explanation is logical. Poorly implemented S2R, potentially related to Anitarf's bug.
3+4: Just the limit of floating point single precision.
07-17-2007, 03:21 AM#4
grim001
If you meant R2S, it's not just a display bug, it's the actual value. It was messing with my conversions between radians and degrees until I deleted the last digit of the variable.

0.000 - 0.000 == 0 now, so it seems like the bug Anitarf posted about is gone. I've also experienced no other real-related glitches in my physics engine.
07-17-2007, 03:43 AM#5
PipeDream
No, I meant the internal ASCII to float routine in warcraft.
The bug Anitarf posted about persists; identical numbers subtract correctly (0 - 0) but ever so slightly different don't, for example code see: http://www.wc3campaigns.net/showpost...4&postcount=10