[bug] Float rounded is inexact

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug] Float rounded is inexact

Nicolas Cellier-3
Issue status update for
http://smalltalk.gnu.org/node/308
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/308

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     minor
 Assigned to:  Unassigned
 Reported by:  nice
 Updated by:   nice
 Status:       active

5000000000000001.0 asExactFraction -> 5000000000000001

This Float is thus represented exactly.
Unfortunately, trying to round it introduces some avoidable
inexactness:

5000000000000001.0 rounded -> 5000000000000002

This is http://bugs.squeak.org/view.php?id=7134
I presume the patch can be ported to gst easily.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [bug] Float rounded is inexact

Paolo Bonzini-3
Issue status update for
http://smalltalk.gnu.org/project/issue/308
Post a follow up:
http://smalltalk.gnu.org/project/comments/add/308

 Project:      GNU Smalltalk
 Version:      <none>
 Component:    Base classes
 Category:     bug reports
 Priority:     minor
 Assigned to:  Unassigned
 Reported by:  nice
 Updated by:   bonzinip
-Status:       active
+Status:       fixed

Indeed.  I added a test to the testsuite too, using

p := (1 bitShift: self precision - 1) + (self coerce: 1.0).
self assert: p rounded = p asExactFraction

I'll be committing the fix soonish.




_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk