A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] float precision question

  1. #1
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136

    resolved [RESOLVED] float precision question

    I'm writing some software to generate nonstandard odds for Keno in an online casino setting.

    To bring out whole number results, I'm using a non-gaussian smoothing function I wrote, that compresses and massages a hyperbolic set of numbers into something useful. My smoothing function runs multiple times on the data and maintains precision up to 99.9999999991% or so after the 3rd iteration.

    In Keno, certain possibilities are extremely remote (in the quintillions) and naturally generate payouts in the billion-dollar range. In order make the game more playable, wildly high paybacks on the outsides of the hyperbola are reduced and refactored toward center based on an initial limiter and compression factor, their value is divided by the difference in odds between the more and less probable outcomes. That division and refactoring is extremely sensitive: Slight modifications in the 16th decimal place can mean hundreds of dollars difference when the smoothing is performed several times.

    The Flash function works like a charm; better than a charm, actually. The problem is, this function MUST sync with the exact same function in PHP, where the REAL payouts are being calculated. On my system, floating point precision in PHP is 3 places less than it is in Flash. Although precision is supposed to be 53-bit for Number and float types in both languages, there is a mismatch directly caused by the three missing decimal places in PHP... the result being that Flash is up to 1% more precise for each run of the function.

    I'd like to keep the Flash level of precision in PHP -- I'm experimenting with the BigNumbers classes on that side -- what I'm wondering is, does anyone have a way to mod the Number type in Flash, should it become necessary, to arbitrarily lower the floating point precision without a huge amount of multiplying, rounding and dividing?

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    Number.toPrecision

  3. #3
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    yyyeah...thx. Not sure if that's gonna solve it for me, but I didn't think about converting to a String and back...

  4. #4
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    Got it. Was actually something limiting the PHP version of the code. Think we're okay now.

    Just outta curiosity, does anybody know how Flash handles 53-bit floating point numbers on systems with a less-than-average FPU?

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