agstod
September 7, 2018, 3:04pm
1
When I want to do the following check:
if ($realtime == 1us)
...
where $realtime gives the value 1.000000005us, this if statement fails because obviously, at the fs level, these two are technically not equal.
Is there a way to multiply/some other operation to the $realtime to force it to round down to the nearest microsecond?
Thanks!
dave_59
September 7, 2018, 3:49pm
2
In reply to ce_2015 :
This a general problem with real numbers and equality. You should try to put your expression in terms of of a relational operator, or cast your expression to an int.
int’($realtime/1us) == 1
agstod
September 7, 2018, 4:55pm
3
In reply to dave_59 :
I knew Dave would have the answer!
Thank you!