The "100 < 1.1*1" problem
Posted: Wed Feb 20, 2019 6:31 pm
Code: Select all
Global.L x
x = 100
If x < 1.0*1
Debug "100 < 1.0*1"
Endif
If x < 1.1*1
Debug "100 < 1.1*1"
Endif
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Global.L x
x = 100
If x < 1.0*1
Debug "100 < 1.0*1"
Endif
If x < 1.1*1
Debug "100 < 1.1*1"
Endif
Code: Select all
Global.L x = 100
Global.d y = 1.0
Global.d z = 1.1
If x < (y)
Debug "BAD! 100 < y"
EndIf
If x < (z)
Debug "BAD! 100 < z"
EndIf
If x < (1.0)
Debug "BAD! 100 < 1.0"
EndIf
If x < (1.1)
Debug "BAD! 100 < 1.1"
EndIf
If x < (1.0 * 1)
Debug "BAD! 100 < 1.0 * 1"
EndIf
If x < (1.1 * 1)
Debug "BAD! 100 < 1.1 * 1"
EndIf
Code: Select all
Global.L x = 100
If x < Int(1.1 * 1)
Debug "BAD! 100 < 1.1 * 1"
EndIf
Code: Select all
Global.L x = 100
If Abs(x) < 1.1 * 1
Debug "BAD! 100 < 1.1 * 1"
EndIf
Code: Select all
Global.i x = 100
If x < 1.1 * 1
Debug "BAD! 100 < 1.1 * 1"
EndIf
If x < Int(1.1 * 1)
Debug "BAD! 100 < Int(1.1 * 1)"
EndIf
If Abs(x) < 1.1 * 1
Debug "BAD! Abs(100) < 1.1 * 1"
EndIf
Code: Select all
Macro Integer(value)
Int((value))
EndMacro
Macro Float(value)
1.0*(value)
EndMacro
Global.i x
x = 100
If x < 1.0*1
Debug "100 < 1.0*1"
EndIf
If x < 1.1*1
Debug "100 < 1.1*1"
EndIf
If x < Integer(1.1*1)
Debug "100 < 1.1*1"
EndIf
If Float(x) < 1.1*1
Debug "100 < 1.1*1"
EndIf