Skip to content

Commit d6c27ae

Browse files
committed
Implemented NAN method for Spin2
1 parent 5fd35fc commit d6c27ae

File tree

4 files changed

+351
-313
lines changed

4 files changed

+351
-313
lines changed

Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version 6.5.3
2+
- Implemented NAN() method for Spin2
23
- Improved error message for objects that are not found
34
- Reduced likelihood of duplicate function definitions in sub-objects
45

frontends/common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ Aliases spin2alias[] = {
218218

219219
{ "strcopy", "__builtin_strncpy" },
220220

221+
{ "nan", "__builtin_isnanf" },
222+
221223
/* obsolete aliases */
222224
{ "outl_", "_outl" },
223225
{ "outh_", "_outh" },

sys/float.spin

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ pri __builtin_copysign(x=float, y=float) : r=float
321321
r := (y>>31) << 31
322322
r |= x
323323

324+
' calculate the log base 2 of a float
324325
pri __builtin_ilogb(a=float) : r=long | s, x, m
325326
(s,x,m) := _float_Unpack(a)
326327
if m == 0
@@ -331,10 +332,19 @@ pri __builtin_ilogb(a=float) : r=long | s, x, m
331332
return $8000_0000 ' NaN
332333
return x
333334

335+
' determine whether a float is NaN or not
336+
pri __builtin_isnanf(a=float) : r | s, x, m
337+
(s,x,m) := _float_Unpack(a)
338+
if x < 128 || m == _float_one
339+
return false
340+
return true
341+
342+
' calculate log2 of a fixed point number
334343
pri __builtin_ilogb_fixed(a) : r=long | n
335344
n := >|a
336345
r := n - 17
337346

347+
' copy the sign of a fixed point number
338348
pri __builtin_copysign_fixed(x, s) : r=long
339349
if s < 0
340350
if x < 0

0 commit comments

Comments
 (0)