Watch-it: Numbers in Excel
In Excel, every number value is treated as a float
, Excel does not have the concept of an int
. This means that if you have a calc that takes in an int
as an input, if a user calls that calculation from Excel then they will pass that input in as a float
.
If your calculation relies on a particular input being an int
and not a float
, and you expect your calculation to be called via Excel, then it is recommended that you accept the input as a float
and then handle the conversion to an int
within the calculation itself.
The conversion can be handled by simply casting the float
value to an int
as shown in the example below:
floatValue = 1.0
intValue = int(floatValue)
print(floatValue) # 1.0
print(intValue) # 1