I\'m writing a program that will calculate factorials of integers. However, the part I\'m stuck on is if someone enters a non-integer such as 1.3
, I\'d like to
By double
command, you cannot get the correct answer:
>> double(uint64(21/22))
ans =
1
>> double(uint64(22/22))
ans =
1
also floor
,round
,... have problem with such cases:
floor(22/22)==21.99999999999999999999999999999999999/22
but mod
seems can distinguish 22/22
and 21.99999999999999999999999999999999999/22
:
>> mod(22,22)
ans =
0
>> (21.99999999999999999999999999999999999/22)
ans =
1