| Anonymous | Login | Signup for a new account | 02-09-2010 14:33 UTC |
| Main | My View | View Issues | Change Log | Docs |
| Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
| ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
| 0003504 | [Squeak] Kernel | minor | always | 04-26-06 04:16 | 04-29-06 22:54 | ||||
| Reporter | nicolas cellier | View Status | public | ||||||
| Assigned To | |||||||||
| Priority | normal | Resolution | fixed | ||||||
| Status | closed | Product Version | 3.9 | ||||||
| Summary | 0003504: Float asInteger conversion is inexact... | ||||||||
| Description |
| x | x := (10 raisedTo: 16) asFloat. { "This one give correctly 0" (x asTrueFraction - (10 raisedTo: 16)) isZero. "This one give incorrectly -1" (x asInteger - (10 raisedTo: 16)) isZero. "Guilty code lie in Float>>truncated: this one give 999999999999999" (x quo: 1073741823.0) * 1073741823 + (x rem: 1073741823.0) truncated. }. |
||||||||
| Additional Information |
Integer numbers are represented exactly in IEEE 754 floating point as long as they do not exceed the mantissa limit (53 bits in double precision). (10 raisedTo: 16) > (2 raisedTo: 53), however, 16 trailing bits are zero... So there is no round of error and (10 raisedTo: 16) is represented exactly. In fact, it is ((5 raisedTo: 16) asFloat timesTwoPower: 16), and (5 raisedTo: 16) < (2 raisedTo: 53). Problem is located in Float>>truncated asTrueFraction does the right job, but other branch with quo: and rem: might imply inexact arithmetic and round off error... |
||||||||
| Attached Files |
|
||||||||
|
|
|||||||||
Relationships |
||||||
|
||||||
| Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
48 total queries executed. 34 unique queries executed. |