Bug in primitive 551 (SmallFloat64>> truncated)

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

Bug in primitive 551 (SmallFloat64>> truncated)

Juan Vuletich-3
 
Hi Folks,

I just found a bug in an edge case in #truncated primitive in 64 bits
Cog Spur (tested on Linux, both in Cuis and Squeak). It is when
#truncated a Float that is slightly larger than SmallInteger maxVal.

SmallInteger maxVal   -->  1152921504606846975

If we take (1152921504606846975.0 predecessor), to ensure a Float that
still fits in a SmallInteger, everything works fine:

1152921504606846975.0 predecessor asTrueFraction   -->  1152921504606846848
1152921504606846975.0 predecessor asTrueFraction   -->  class SmallInteger
1152921504606846975.0 predecessor truncated   -->  1152921504606846848

But taking 1152921504606846976.0:

1152921504606846976.0 asTrueFraction   -->  1152921504606846976 (correct
result)
1152921504606846976.0 asTrueFraction class   -->  LargePositiveInteger
(ok. Doesn't fit in SmallInteger)
1152921504606846976.0 truncated   -->  -1152921504606846976

The primitive is answering SmallInteger minVal, (a negative number!) but
it should fail, as the correct result doesn't fit in a SmallInteger.

Thanks,

--
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich


Reply | Threaded
Open this post in threaded view
|

Re: Bug in primitive 551 (SmallFloat64>> truncated)

Nicolas Cellier
 
Hi Juan,
good find. Can you open an issue on github opensmalltalk repo?

Le mar. 12 mars 2019 à 16:05, Juan Vuletich <[hidden email]> a écrit :
 
Hi Folks,

I just found a bug in an edge case in #truncated primitive in 64 bits
Cog Spur (tested on Linux, both in Cuis and Squeak). It is when
#truncated a Float that is slightly larger than SmallInteger maxVal.

SmallInteger maxVal   -->  1152921504606846975

If we take (1152921504606846975.0 predecessor), to ensure a Float that
still fits in a SmallInteger, everything works fine:

1152921504606846975.0 predecessor asTrueFraction   -->  1152921504606846848
1152921504606846975.0 predecessor asTrueFraction   -->  class SmallInteger
1152921504606846975.0 predecessor truncated   -->  1152921504606846848

But taking 1152921504606846976.0:

1152921504606846976.0 asTrueFraction   -->  1152921504606846976 (correct
result)
1152921504606846976.0 asTrueFraction class   -->  LargePositiveInteger
(ok. Doesn't fit in SmallInteger)
1152921504606846976.0 truncated   -->  -1152921504606846976

The primitive is answering SmallInteger minVal, (a negative number!) but
it should fail, as the correct result doesn't fit in a SmallInteger.

Thanks,

--
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich


Reply | Threaded
Open this post in threaded view
|

Re: Bug in primitive 551 (SmallFloat64>> truncated)

Juan Vuletich-3
 
Hi Nicolas,

Done. It is https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/376

Thanks,
-- 
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich


On 3/12/2019 1:05 PM, Nicolas Cellier wrote:
Hi Juan,
good find. Can you open an issue on github opensmalltalk repo?

Le mar. 12 mars 2019 à 16:05, Juan Vuletich <[hidden email]> a écrit :
 
Hi Folks,

I just found a bug in an edge case in #truncated primitive in 64 bits
Cog Spur (tested on Linux, both in Cuis and Squeak). It is when
#truncated a Float that is slightly larger than SmallInteger maxVal.

SmallInteger maxVal   -->  1152921504606846975

If we take (1152921504606846975.0 predecessor), to ensure a Float that
still fits in a SmallInteger, everything works fine:

1152921504606846975.0 predecessor asTrueFraction   -->  1152921504606846848
1152921504606846975.0 predecessor asTrueFraction   -->  class SmallInteger
1152921504606846975.0 predecessor truncated   -->  1152921504606846848

But taking 1152921504606846976.0:

1152921504606846976.0 asTrueFraction   -->  1152921504606846976 (correct
result)
1152921504606846976.0 asTrueFraction class   -->  LargePositiveInteger
(ok. Doesn't fit in SmallInteger)
1152921504606846976.0 truncated   -->  -1152921504606846976

The primitive is answering SmallInteger minVal, (a negative number!) but
it should fail, as the correct result doesn't fit in a SmallInteger.

Thanks,

--
Juan Vuletich
www.cuis-smalltalk.org
https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev
https://github.com/jvuletich
https://www.linkedin.com/in/juan-vuletich-75611b3
@JuanVuletich