Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

to-integer problem

 [1/7] from: smith::munsterman::com at: 16-Apr-2003 8:44


I get the same results on REBOL/View 1.2.1.3.1. I do believe there is a problem. Have you sent feedback to the Rebol folks? -Jeff Smith On Wed, 16 Apr 2003 14:18:24 +0200, Will Arp <[warp--reboot--ch]> wrote:
> I really don't understand >>> to-integer (1.10 * 100)
<<quoted lines omitted: 21>>
> Will Arp > [warp--reboot--ch]
-- -Jeff Smith 770-565-5462

 [2/7] from: warp:reboot:ch at: 16-Apr-2003 13:47


Hi all 8)
>>to-integer (1.14 * 100)
== 113 Is this a bug or am I missing something? Thank you Will Arp [warp--reboot--ch]

 [3/7] from: warp:reboot:ch at: 16-Apr-2003 14:18


I really don't understand
>> to-integer (1.10 * 100)
== 110
>> to-integer (1.11 * 100)
== 111
>> to-integer (1.12 * 100)
== 112
>> to-integer (1.13 * 100)
== 112
>> to-integer (1.14 * 100)
== 113
>> to-integer (1.15 * 100)
== 114
>> to-integer (1.16 * 100)
== 115
>> to-integer (1.17 * 100)
== 117
>> to-integer (1.18 * 100)
== 118
>> to-integer (1.19 * 100)
== 119 using REBOL/Core 2.5.5.2.4 Thank you Will Arp [warp--reboot--ch]

 [4/7] from: lmecir:mbox:vol:cz at: 16-Apr-2003 15:33


Hi Jeff and Will,
> I get the same results on REBOL/View 1.2.1.3.1. I do believe there is a > problem. Have you sent feedback to the Rebol folks? > > -Jeff Smith
actually, there is no problem. This behaviour is "forced" by the fact, that binary floating point numbers cannot exactly represent a number like 1.14 If you want to get 114, you can do as follows: to integer! round 1.14 * 100 Or use any similar expression. ( see http://www.fm.vslib.cz/~ladislav/rebol/rounding.r ) Regards -Ladislav

 [5/7] from: joel:neely:fedex at: 16-Apr-2003 7:24


Hi, Will, Will Arp wrote:
> Hi all 8) > > >>to-integer (1.14 * 100) > == 113 > > Is this a bug or am I missing something? > >> to-integer (1.14 * 100)
== 113
>> (1.14 * 100)
== 114
>> (1.14 * 100) - 114
== -1.4210854715202E-14
>> (1.14 * 100) - to-integer(1.14 * 100)
== 0.999999999999986 Two issues: 1) rounding error in decimal-binary/binary-decimal conversion, 2) assumptions made in the floating-point-to-string conversion about how much difference was worth bringing to the user's attention. -- Polonius: ... What do you read, my lord? Hamlet: Words, words, words. _Hamlet_, Act II, Scene 2

 [6/7] from: smith:munsterman at: 16-Apr-2003 12:26


Hi Ladislav, You are correct. Thanks for the link to some of your code. I appreciate your response. -Jeff PS Perl (sorry :=}) treats this issue exactly the same way. In this case, 1.13-1.16 are all 1 less than you might expect. On Wed, 16 Apr 2003 15:33:43 +0200, Ladislav Mecir <[lmecir--mbox--vol--cz]> wrote:
> Hi Jeff and Will, >> I get the same results on REBOL/View 1.2.1.3.1. I do believe there is a
<<quoted lines omitted: 13>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
-- -Jeff Smith 770-565-5462

 [7/7] from: warp:reboot:ch at: 17-Apr-2003 2:15


Thank you Joel, Jeff & Ladislav, I'll use Ladislav's rounding.r functions 8) Will Arp [warp--reboot--ch]

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted