A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Deterministic Floating Point

  1. #1
    Junior Member
    Join Date
    Jan 2006
    Posts
    16

    Deterministic Floating Point

    Has anyone ever encountered any inconsistencies while using floating point values?

    Eg:
    On computer one: Math.sin(1) = 0.841470984807897
    On computer two: Math.sin(1) = 0.841470984807898

    I'm creating a car racing game which will have a replay system, but I need the engine to be completely deterministic. Differences like the above could quickly put it out of sync on different computer.

    If this does happen, does anyone know how I could still use trigonometry functions without fear of this?

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    so do not accumulate these differences. instead of saving x0, and then dx1, dx2, dx3 save x0, x1, x2, x3 for every variable. then, even if you do some kind of "slow motion" replay, and it will be inaccurate inbetween, you would still have close match at control points.
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Junior Member
    Join Date
    Jan 2006
    Posts
    16
    Thats true, but it would require far more save data. I was thinking more along the lines of 1 byte holding all the key input data each frame, rather than the 10 or bytes to store state data.

    If all else fails ill just save state data every few seconds, I'm sure the sim wouldn't get too far off in that time...

  4. #4
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    well somewhere down this very forum you might find a class for fractional numbers I wrote one day, which is free of floating point problems, but is also very slow maybe just rounding sin/cos somewhere on their way will help.
    who is this? a word of friendly advice: FFS stop using AS2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center