In trying to get some timing information I was surprised to
find that subtracting two 10 digit integers failed to produce
the expected result. Is there a way to get houdini expressions
to evaluate big ints correctly?
/ -> set START = `system(“date +%s”)`
/ -> echo $START
1287171710
/ -> set END = `system(“date +%s”)`
/ -> echo $END
1287171723
/ -> echo `eval($START)`
1.28717e+09
/ -> echo `eval($END)`
1.28717e+09
/ -> echo `$END - $START`
0
/ -> echo `system(“echo $END - $START | bc”)`
13
integer precision only 8 bit?
3119 5 1- sdugaro
- Member
- 380 posts
- Joined: July 2005
- Offline
- mark
- Staff
- 2592 posts
- Joined: July 2005
- Offline
sdugaro
In trying to get some timing information I was surprised to
find that subtracting two 10 digit integers failed to produce
the expected result. Is there a way to get houdini expressions
to evaluate big ints correctly?
/ -> set START = `system(“date +%s”)`
/ -> echo $START
1287171710
/ -> set END = `system(“date +%s”)`
/ -> echo $END
1287171723
/ -> echo `eval($START)`
1.28717e+09
/ -> echo `eval($END)`
1.28717e+09
/ -> echo `$END - $START`
0
/ -> echo `system(“echo $END - $START | bc”)`
13
Houdini expressions don't have an integer type. You can always do something like:
/ -> set START = `system(“date +%s”)`
/ -> set END = `system(“date +%s”)`
/ -> echo `pythonexprf(“$END - $START”)`
5
though if you want long integer arithmetic. Of course, you could also just use Python. This example stores the time as a string rather than a float to get Python's precision out…
/ -> set START = `pythonexprs(“__import__('time').time()”)`
/ -> set END = `pythonexprs(“__import__('time').time()”)`
/ -> echo $START, $END, `$END-$START`
1287173486.81, 1287173492.75, 5.94
/ ->
- wolfwood
- Member
- 4262 posts
- Joined: July 2005
- Offline
- sdugaro
- Member
- 380 posts
- Joined: July 2005
- Offline
- sdugaro
- Member
- 380 posts
- Joined: July 2005
- Offline
Hmm, thought to inline and format… any idea why this fails?
/ -> set START = `pythonexprs(“__import__('time').time()”)`
/ -> set END = `pythonexprs(“__import__('time').time()”)`
/ -> echo `pythonexprs(“$END - $START”)`
4.74000000954
/ -> echo `pythonexprs(“'%.3f'%($END - $START)”)`
File <stdin>, line 1 %.3f%(1287177562.79 - 1287177558.05) ^ SyntaxError: invalid syntax
/ -> echo `pythonexprs(“__import__('time').time() - $START”)`
Traceback (most recent call last): File <stdin>, line 1, in <module> NameError: name time is not defined
/ -> echo `pythonexprs(“'%.3f'%(12.34567890 - 2.345)”)`
10.001
/ -> set START = `pythonexprs(“__import__('time').time()”)`
/ -> set END = `pythonexprs(“__import__('time').time()”)`
/ -> echo `pythonexprs(“$END - $START”)`
4.74000000954
/ -> echo `pythonexprs(“'%.3f'%($END - $START)”)`
File <stdin>, line 1 %.3f%(1287177562.79 - 1287177558.05) ^ SyntaxError: invalid syntax
/ -> echo `pythonexprs(“__import__('time').time() - $START”)`
Traceback (most recent call last): File <stdin>, line 1, in <module> NameError: name time is not defined
/ -> echo `pythonexprs(“'%.3f'%(12.34567890 - 2.345)”)`
10.001
- sdugaro
- Member
- 380 posts
- Joined: July 2005
- Offline
-
- Quick Links