Hello,
It is a bug.. or? FloatArray newFrom: {0.938611557944869}. Expecting result is the entered float number, but evaluating gives - a FloatArray(0.938611567020416). Nikolay |
On Dec 20, 2008, at 5:54 PM, Nikolay Suslov wrote:
> Hello, > > It is a bug.. or? No. > FloatArray newFrom: {0.938611557944869}. > Expecting result is the entered float number, but evaluating gives - > a FloatArray(0.938611567020416). The comment in the #'newFrom:' methods reads as follows: "Answer an instance of me containing the same elements as aCollection." What the above does is take a float, add it to an Array, then create a FloatArray and add to it each element in the Array. If you want just the float number, you already have it: 0.938611557944869 class == Float James Foster > Nikolay |
On 21/12/2008, at 12:57 PM, James Foster wrote: >> FloatArray newFrom: {0.938611557944869}. >> Expecting result is the entered float number, but evaluating gives >> - a FloatArray(0.938611567020416). > > The comment in the #'newFrom:' methods reads as follows: "Answer an > instance of me containing the same elements as aCollection." What > the above does is take a float, add it to an Array, then create a > FloatArray and add to it each element in the Array. > > If you want just the float number, you already have it: > > 0.938611557944869 class == Float I think Nikolay's point is that the number isn't the same. Antony Blakey ------------- CTO, Linkuistics Pty Ltd Ph: 0438 840 787 It's amazing that the one side of the conversation that survived is "I don't know art, but I know what I like". The reply from the artist was "Madam, so does a cow". -- Carl Kirkendall |
In reply to this post by Nikolay Suslov
On Dec 20, 2008, at 5:54 PM, Nikolay Suslov wrote:
> Hello, > > It is a bug.. or? A misunderstanding. > FloatArray newFrom: {0.938611557944869}. > Expecting result is the entered float number, but evaluating gives - > a FloatArray(0.938611567020416). Float has the following class comment: "My instances represent IEEE-754 floating-point double-precision numbers." FloatArray has the following class comment: "FloatArrays store 32bit IEEE floating point numbers." I think what you are seeing is the conversion of 64-bit floating point to 32-bit floating point. Sorry for the initial confusion about your expected result. James > Nikolay |
2008/12/21 James Foster <[hidden email]>:
> On Dec 20, 2008, at 5:54 PM, Nikolay Suslov wrote: > >> Hello, >> >> It is a bug.. or? > > A misunderstanding. > >> FloatArray newFrom: {0.938611557944869}. >> Expecting result is the entered float number, but evaluating gives - a >> FloatArray(0.938611567020416). > > Float has the following class comment: "My instances represent IEEE-754 > floating-point double-precision numbers." > FloatArray has the following class comment: "FloatArrays store 32bit IEEE > floating point numbers." > > I think what you are seeing is the conversion of 64-bit floating point to > 32-bit floating point. Sorry for the initial confusion about your expected > result. Even it that wouldn't be the case it would still be floating point numbers and imprecise by design. Additionally not every decimal number can be represented by a floating point number. Cheers Philippe |
In reply to this post by jgfoster
James,
Sorry for not clear problem statement, Yes, the unexpected result is that the float number isn't the same, after adding to FloatArray. Thanks, Nikolay On Sun, Dec 21, 2008 at 4:18 AM, James Foster <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |