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

integers and sizes

 [1/5] from: twatkins:datajunction at: 18-Apr-2001 17:38


I fear that this may be a bug: Integer? 10000000005 false (this is correct because you only use 4 bytes to represent an integer) integer? 2000000001 true integer? (10000000005 / 5) false (note, this is 2000000001, the value which was true before) apparently any number which was at one point associated with a value greater than an integer is not an integer, even when reduced to a sufficently small number. Note: Win98 system

 [2/5] from: holger:rebol at: 18-Apr-2001 15:57


On Wed, Apr 18, 2001 at 05:38:02PM -0500, Travis Watkins wrote:
> I fear that this may be a bug: > Integer? 10000000005
<<quoted lines omitted: 4>>
> false > (note, this is 2000000001, the value which was true before)
Actually this is correct behavior. 10000000005 is a decimal! because it is too large to fit into an integer!. Dividing a decimal! by an integer! results in another decimal!. -- Holger Kruse [holger--rebol--com]

 [3/5] from: gjones05:mail:orion at: 18-Apr-2001 18:16


From: "Travis Watkins"
> I fear that this may be a bug: > > Integer? 10000000005 > false (this is correct because you only use 4 bytes to represent an
integer)
> integer? 2000000001 > true > > integer? (10000000005 / 5) > false > (note, this is 2000000001, the value which was true before) > > apparently any number which was at one point associated with a value
greater than an integer is not an integer, even when reduced to a sufficently small number.
> Note: Win98 system
Well, this does get interesting. To continue with your example: a: 2000000001 b: 10000000005 / 5 type? a ;integer! type? b ;decimal! a = b ;true, as it should be same? a b ;true, as I guess it is strict-equal? a b ;false, ahhh, I feel better to-integer b ; 2000000001 type? b ;decimal!, wow, that is interesting to-decimal a ;2000000001 type? c ;integer! It is interesting that sometimes REBOL "leaves" it as it was (a decimal or an integer), despite trying to coerce it. I can't tell if this is a bug or a feature, but I could imagine circumstances where it might trip up programming logic. Thanks. --Scott Jones

 [4/5] from: sterling::rebol::com at: 18-Apr-2001 16:38


It all looks right. The to- conversions are just that and do not transform a value into another value. They are conversions which means that they return a new value of the new type as long as the original type can be converted into the target type. To work with your examples: a: 2000000001 b: 10000000005 / 5 type? a ;integer! type? b ;decimal! to-integer b ; 2000000001 type? b ;decimal!, wow, that is interesting to-decimal a ;2000000001 but: c: to-integer b ; 2000000001 type? c ; integer! c: to-decimal a ;2000000001 type? c ; decimal! The same thing works with series values that have extra storage associated with them: a: "foo" type? a ; string! b: to-issue a type? a ; string! -- still type? b ; issue! -- converted insert a "bar-" a == "bar-foo" b == #foo when b was converted from the string "foo" to the issue #foo it was copied and therefore is a new value. If the old value is changed, the new value is unaffected. Sterling

 [5/5] from: gjones05:mail:orion at: 18-Apr-2001 19:09


From: <[sterling--rebol--com]>
> The to- conversions are just that and do not transform a value into > another value. They are conversions which means that they return a > new value of the new type as long as the original type can be > converted into the target type. <snip>
Thanks, Sterling, for clearing up my confusion. --Scott Jones

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