SphereServer BugTracker - SphereServer
View Issue Details
0002572SphereServerexecutable - genericpublic23-01-16 15:5711-07-16 21:43
nolok 
 
normaltrivialalways
newopen 
 
 
Automated (specify build number)
None
None
0002572: FLOATVAL error with ABS and issue with SQRT
.show eval ABS(-1) shows 1.
.show floatval ABS(-1) shows 0.000000 and error in console: Bad intrinsic function usage. missing ).

.show eval SQRT(030) shows 6.
.show eval SQRT(30) shows 5.
So with eval it appear to work properly.

.show floatval SQRT(030) shows 5.77...
.show floatval SQRT(30) shows 5.77...
It's like now it doesn't do the conversion from hex to decimal.

FLOATVAL doesn't show error in console if i put invalid code inside, like .show FLOATVAL arrraaa, where EVAL arrraaa does.

Also, is it possible to have as intrinsic functions also arcsin, arccos, arctan, arccotan? It should be easy to do since they are already in the c++ header <cmath.h> (http://www.cplusplus.com/reference/cmath/ [^]); cotan and arccotan appear to not be included, but cotan is 1/tan and arccotan is 90°-arctan (https://en.wikipedia.org/wiki/Inverse_trigonometric_functions [^]).
No tags attached.
Issue History
23-01-16 15:57nolokNew Issue
11-07-16 21:43CorujaNote Added: 0003017

Notes
(0003017)
Coruja   
11-07-16 21:43   
these intrinsic functions (FLOATVAL, ABS, ...) usually don't evaluate args, they just read them exactly as it is. So to make the function work properly the args must be already using the correct syntax

example:
<eval ABS(-1)> -> this works fine because EVAL can evaluate all values before the calculation, so it will first resolve ABS(-1) to 1 and later will call 'eval 1'

<floatval ABS(-1)> -> this will not work because FLOATVAL doesn't evaluate the args before the calculation. So instead resolve ABS(-1) to 1 and call 'floatval 1', it will thread ABS(-1) as an numeric value without change it. And since ABS(-1) is an string (text) and not an numeric value, FLOATVAL will fail

to fix this, you must evaluate these values before call intrinsic functions, like this:
<FLOATVAL <eval ABS(-1)>> = <FLOATVAL 1> = 1.000000

the same occur when you call these functions using hex args instead dec, like <FLOATVAL 0a>. The function will thread 0a as numeric, but will fail because it doesn't evaluate args so it doesn't know that 0a (hex) is the same of 10 (dec). So to make it work properly you must fist evaluate this value to dec using something like <FLOATVAL <eval 0a>> or <FLOATVAL 10>