Shouldn't 7r6.5 be the same as 7r65 * 0.1

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

Shouldn't 7r6.5 be the same as 7r65 * 0.1

Klaus D. Witzel
Would some good soul please explain what

        Number readFrom: '7r6.5'

should return. It is apparently not the same as 7r65 * 0.1 and before I  
dig deeper (why does this happen, is it a bug or feature) I'd appreciate  
that someone confirms or rejects (bug | feature).

Thank you.

/Klaus


Reply | Threaded
Open this post in threaded view
|

Re: Shouldn't 7r6.5 be the same as 7r65 * 0.1

Ken Causey-3
On Mon, 2006-07-03 at 20:30 +0200, Klaus D. Witzel wrote:

> Would some good soul please explain what
>
> Number readFrom: '7r6.5'
>
> should return. It is apparently not the same as 7r65 * 0.1 and before I  
> dig deeper (why does this happen, is it a bug or feature) I'd appreciate  
> that someone confirms or rejects (bug | feature).
>
> Thank you.
>
> /Klaus
Because in the expression

7r65 * 0.1

the first value is in base 7 whereas the second is in base 10

7r65 * 7r0.1 IS the same valus as 7r6.5.

Ken



signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Shouldn't 7r6.5 be the same as 7r65 * 0.1

Klaus D. Witzel
Hi Ken,

on Mon, 03 Jul 2006 20:51:00 +0200, you wrote:

> On Mon, 2006-07-03 at 20:30 +0200, Klaus D. Witzel wrote:
>> Would some good soul please explain what
>>
>> Number readFrom: '7r6.5'
>>
>> should return. It is apparently not the same as 7r65 * 0.1 and before I
>> dig deeper (why does this happen, is it a bug or feature) I'd appreciate
>> that someone confirms or rejects (bug | feature).
>>
>> Thank you.
>>
>> /Klaus
>
> Because in the expression
>
> 7r65 * 0.1
>
> the first value is in base 7 whereas the second is in base 10
>
> 7r65 * 7r0.1 IS the same valus as 7r6.5.

Ah! This equation cut my knot, thank you Ken.

/Klaus

> Ken



Reply | Threaded
Open this post in threaded view
|

Re: Shouldn't 7r6.5 be the same as 7r65 * 0.1

Wolfgang Helbig-2
In reply to this post by Klaus D. Witzel
Klaus, you asked:
>Would some good soul please explain what
>
> Number readFrom: '7r6.5'

And here is the good soul's answer:

7r6.5 = 6*7^0 + 5 * 7^(-1) = 6 + 5/7 = 6.714285714285... with the last
6 digits repeating at infinitum.

Whereas 7r65 * 0.1 should evaluate to
7r65 * 0.1 = (6*7^1 + 5*7^0) * 10^-1 = (6*7 + 5) / 10 = 4.7

(Notation: "^" is the exponentation operator, like 3^2 = 3 * 3 = 9).

Greetings,
Wolfgang

--
"Dijkstra is right, but you don't say such things!"
(A less courageous programmer)


Reply | Threaded
Open this post in threaded view
|

Re: Shouldn't 7r6.5 be the same as 7r65 * 0.1

Klaus D. Witzel
Thank you Wolfgang (did you see the response from Ken).

But one thing remains: in 7r6.5e4 the exponent is also computed base 7,  
contrary to the comment in NumberParsingTest>>#testFloatReadWithRadix.

/Klaus

On Tue, 04 Jul 2006 20:11:04 +0200, Wolfgang Helbig wrote:

> Klaus, you asked:
>> Would some good soul please explain what
>>
>> Number readFrom: '7r6.5'
>
> And here is the good soul's answer:
>
> 7r6.5 = 6*7^0 + 5 * 7^(-1) = 6 + 5/7 = 6.714285714285... with the last
> 6 digits repeating at infinitum.
>
> Whereas 7r65 * 0.1 should evaluate to
> 7r65 * 0.1 = (6*7^1 + 5*7^0) * 10^-1 = (6*7 + 5) / 10 = 4.7
>
> (Notation: "^" is the exponentation operator, like 3^2 = 3 * 3 = 9).
>
> Greetings,
> Wolfgang
>
> --
> "Dijkstra is right, but you don't say such things!"
> (A less courageous programmer)
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Shouldn't 7r6.5 be the same as 7r65 * 0.1

Nicolas Cellier-3
In reply to this post by Klaus D. Witzel

Yes, 7r6.5e4 is equivalent to 7r65000.0
That is the natural behavior we would expect i think

To be more precise, however, the number on the right of exponent e is interpreted in base 10.
let us take another example:

7r6.5e12 is (6*7^0+5*7^-1) * 7^12 that is 6*7^12+5*7^11
it is not interpreted as (6*7^0+5*7^-1) * 7^ 7r12 that is 6*7^9+5*7^8

Nicolas


Klaus D. Witzel:

> Thank you Wolfgang (did you see the response from Ken).
>
> But one thing remains: in 7r6.5e4 the exponent is also computed base 7,  
> contrary to the comment in NumberParsingTest>>#testFloatReadWithRadix.
>
> /Klaus
>
> On Tue, 04 Jul 2006 20:11:04 +0200, Wolfgang Helbig wrote:
>
> > Klaus, you asked:
> >> Would some good soul please explain what
> >>
> >> Number readFrom: '7r6.5'
> >
> > And here is the good soul's answer:
> >
> > 7r6.5 = 6*7^0 + 5 * 7^(-1) = 6 + 5/7 = 6.714285714285... with the last
> > 6 digits repeating at infinitum.
> >
> > Whereas 7r65 * 0.1 should evaluate to
> > 7r65 * 0.1 = (6*7^1 + 5*7^0) * 10^-1 = (6*7 + 5) / 10 = 4.7
> >
> > (Notation: "^" is the exponentation operator, like 3^2 = 3 * 3 = 9).
> >
> > Greetings,
> > Wolfgang
> >
> > --
> > "Dijkstra is right, but you don't say such things!"
> > (A less courageous programmer)
> >
> >
> >
>
>
>
>

________________________________________________________________________
iFRANCE, exprimez-vous !
http://web.ifrance.com