"FloatQ fmin log: 10" fails
| Project: | GNU Smalltalk |
| Component: | Base classes |
| Category: | bug |
| Priority: | normal |
| Assigned: | bonzinip |
| Status: | fixed |
Hi Paolo here the the stack trace when I've tried to send displayString a Float (I am not sur if it was NaN)
Object: -inf error: Infinity can only be a Float
ArithmeticError(Exception)>>signal (AnsiExcept.st:216)
ArithmeticError(Exception)>>signal: (AnsiExcept.st:226)
FloatD(Number)>>arithmeticError: (AnsiExcept.st:1526)
FloatD(Float)>>checkCoercion (Float.st:470)
FloatD(Float)>>floor (Float.st:633)
FloatQ(Float)>>floorLog: (Float.st:360)
FloatQ(Float)>>printOn:special: (Float.st:502)
FloatQ(Float)>>printOn: (Float.st:430)
FloatQ(Object)>>displayOn: (Object.st:505)
FloatQ(Object)>>displayString (Object.st:496)
Updates
To reproduce this bug :
FloatQ allInstances and I've st> FloatQ allInstances
Object: -inf error: Infinity can only be a Float
ArithmeticError(Exception)>>signal (AnsiExcept.st:216)
ArithmeticError(Exception)>>signal: (AnsiExcept.st:226)
FloatD(Number)>>arithmeticError: (AnsiExcept.st:1526)
FloatD(Float)>>checkCoercion (Float.st:470)
FloatD(Float)>>floor (Float.st:633)
FloatQ(Float)>>floorLog: (Float.st:360)
FloatQ(Float)>>printOn:special: (Float.st:502)
FloatQ(Float)>>printOn: (Float.st:430)
[] in WeakArray(Array)>>printOn: (Array.st:60)
Array(SequenceableCollection)>>do: (SeqCollect.st:823)
WeakArray>>do: (WeakObjects.st:140)
WeakArray(Array)>>printOn: (Array.st:61)
WeakArray(Object)>>printString (Object.st:535)
WeakArray(Object)>>printNl ("Global garbage collection... done"
Object.st:571)
| Title: | displayString on a FloatQ failed | » "FloatQ fmin log: 10" fails |
| Assigned to: | Unassigned | » bonzinip |
The root cause of the bug is this
st> FloatQ fmin log: 10 -Inf
| Status: | active | » fixed |
And here is the fix, pushed as 6f7344d:
diff --git a/kernel/Float.st b/kernel/Float.st
index af73a86..f3affe7 100644
--- a/kernel/Float.st
+++ b/kernel/Float.st
@@ -319,6 +319,13 @@ if the hardware supports it.'>
^self ln / self class ln10
]
+ log: aNumber [
+ "Answer log base aNumber of the receiver"
+
+
+ ^self ln / (self coerce: aNumber) ln
+ ]
+
ceilingLog: radix [
"Answer (self log: radix) ceiling."
