SphereServer BugTracker - SphereServer
View Issue Details
0002503SphereServerexecutable - windows buildpublic27-04-15 21:2810-05-15 17:31
babidi 
Ben 
normalmajoralways
resolvedfixed 
16-06-2013, 0.56b Prerelease 
0.56c Nightly 
Automated (specify build number)
None
None
2256
0002503: UVAL DON'T WORK
UVAL DID NOT WORK.

UVAL expression R Evaluates an expression and returns the result as an unsigned integer.
[FUNCTION FTUV]
LOCAL.NEG = -1
LOCAL.NUMN = -5
LOCAL.NUMP = 5
LOCAL.FTUVA = <UVAL <LOCAL.NUMN>>
LOCAL.FTUVB = <EVAL <LOCAL.NUMN>*<LOCAL.NEG>>
LOCAL.FTUVC = <UVAL <LOCAL.NUMN>*<LOCAL.NUMP>>
SERV.B <DLOCAL.FTUVA> <DLOCAL.FTUVB> <DLOCAL.FTUVC> // EXPECTED 5 5 25 RESULT -5 5 -25
No tags attached.
Issue History
27-04-15 21:28babidiNew Issue
28-04-15 00:59CorujaNote Added: 0002771
28-04-15 01:03CorujaNote Edited: 0002771bug_revision_view_page.php?bugnote_id=0002771#r856
10-05-15 17:31BenNote Added: 0002796
10-05-15 17:31BenStatusnew => resolved
10-05-15 17:31BenFixed in Version => 0.56c Nightly
10-05-15 17:31BenResolutionopen => fixed
10-05-15 17:31BenAssigned To => Ben

Notes
(0002771)
Coruja   
28-04-15 00:59   
(edited on: 28-04-15 01:03)
I tried it here and it's really broken

but note that converting a NEGATIVE signed number to unsigned will not simply keep the same number and just remove the signal. Unsigned numbers cant have negative values, so when it reach the minimum value (0) it will jump to the max value (2³² = 4294967296) instead just remove the signal from the number

so unsigned -5 is 4294967291 (the same as 4294967296 - 5) and not 5

I will keep this thread open because UVAL is not really working (it just print the same value without change it to unsigned) but probably even after it got fixed, it wont work on your function as you expect

maybe you can use another workaround that simply remove the signal if the value is negative instead change it to unsigned

[FUNCTION RemoveSignal]
IF (<ARGS> < 0)
 ARGS = <STRSUB 1 0 <dARGS>>
ENDIF
return <ARGS>

so if you use <RemoveSignal -5> it will return 5. Or you can simply use an *-1 directly on your formula without need to create another function

IF (<LOCAL.A> < 0)
 LOCAL.A *= -1
ENDIF

if LOCAL.A = -5 this will change it to LOCAL.A = 5

(0002796)
Ben   
10-05-15 17:31   
ok... tested, fix some issues, but really this worked as intended. The only issue I saw was that it was working with int32 while all storage variables use int64 now, so UVAL -5 = 18446744073709551611 now, not 4294967291.

Now let me explain how it works.
Locals, tags, vars... are signed int64 values.
When you save -5 to a local, it's saved as -5. (it will display as 0fffffffffffffffb in hex)
When you save 18446744073709551611, it saves as -5 (it will display as 0fffffffffffffffb in hex)
If you wish to display an unsigned value, you must use UVAL when displaying since you can't save an unsigned value to any storage variables

What you are looking for is a function called abs() which returns the number without the sign. I'll see about adding that in.