Projects

Ticket #611 (new defect)

Opened 2 years ago

Last modified 14 months ago

MacRuby floats are less precise than CRuby floats

Reported by: dj2@… Owned by: lsansonetti@…
Priority: major Milestone: MacRuby Later
Component: MacRuby Keywords:
Cc:

Description

JSON decoding of floating point numbers sometimes loses accuracy. e.g.

'{"http:\/\/www.schneier.com\/blog\/archives\/2010\/02\/10_cartoons_abo.html": {"postrank": 8.1, "postrank_color": "#ff883d"}}'

MacRuby

{"http://www.schneier.com/blog/archives/2010/02/10_cartoons_abo.html"=>{"postrank"=>8.09999999999999, "postrank_color"=>"#ff883d"}}

Ruby 1.8.7

{"http://www.schneier.com/blog/archives/2010/02/10_cartoons_abo.html"=>{"postrank"=>8.1, "postrank_color"=>"#ff883d"}}

Attachments

811.rb Download (60 bytes) - added by emil@… 14 months ago.
reduction
611.rb Download (60 bytes) - added by emil@… 14 months ago.
reduction

Change History

Changed 14 months ago by emil@…

reduction

Changed 14 months ago by emil@…

i believe this has nothing to do with json, since simply doing puts 8.1 will output 8.09999999999999 on turnk rev 4976

Changed 14 months ago by emil@…

reduction

Changed 14 months ago by lsansonetti@…

  • milestone set to MacRuby Later

Indeed, MacRuby's floats are less precise as we store them as immediate values, so 2 bits of precision are loss. I don't think we can do anything for 1.0, moving to later.

Changed 14 months ago by lsansonetti@…

  • summary changed from Error decoding JSON floating point number to MacRuby floats are less precise than CRuby floats
Note: See TracTickets for help on using tickets.