I am new in tcl. I am trying to check if a given number is a whole number but can't seem to find a simple way to do this.
So I have a number2 which is checking if it is on grid. If not a whole number then it is not on grid.
set numberOne 7.5
set grid 2.5
set numberTwo [expr ($numberOne/$grid) ]
if {[string is integer -strict $numberTwo} {
do something
} else {
do something else
}
The above code does not work for me since the numberTwo is going to be returned as a floating point number (3.0 in this case)
Python has something like this:
x = 7.5
y = 2.5
z = x/y
if z%1 == 0
then do something
else
do something else
Is there a way to do something similar in tcl? If not another alternative could be -
- take the decimal value of the numberTwo and check if it is 0 or non-0
So something that takes 6.555 returns 555 and takes 6.0 and returns 0. I can then do:
if {$value == 0} {then do something} else {do something else}