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
> 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
>
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.