#Inf #Nan #QNan or negative

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

 

sinjin

Betreff: #Inf #Nan #QNan or negative

BeitragMo, März 30, 2020 21:48
Antworten mit Zitat
Benutzer-Profile anzeigen
Falls es jemand schneller haben möchte als nen String nach "#Nan" abzufragen, hier der Code:

"nan.bmx"
Code: [AUSKLAPPEN]

import "nan.s"
extern
  function isind%(src#) '0=none 1=qnan 2=inf 3=nan
endextern



"nan.s"
Code: [AUSKLAPPEN]

;(Hab den Text von der Wiki eingefügt)
;A bit-wise IEEE floating-point standard single precision (32-bit) NaN would be
;    s111 1111 1xxx xxxx xxxx xxxx xxxx xxxx
;where s is the sign (most often ignored in applications) and the x sequence represents
;a non-zero number (the value zero encodes infinities). The first bit from x is used to
;determine the type of NaN: "quiet NaN" or "signaling NaN". The remaining bits encode
;a payload (most often ignored in applications).

;in esp+4 float
;out 0=none 1=qnan 2=inf 3=nan. or negative for minus values
public _isind
_isind:
  mov edx,[esp+4]
  xor eax,eax
  or edx,edx
 jz .out
  not edx
  test edx,$7f800000
 jnz .out
  inc al
  not edx
  test edx,$3fffff
 jnz .j1
  inc al
.j1:
  test edx,$400000
 jnz .j2
  mov al,3
.j2:
  shl edx,1
 jnc .out
  neg eax
.out:
ret

DAK

BeitragDi, März 31, 2020 10:08
Antworten mit Zitat
Benutzer-Profile anzeigen
Dafür gibt es doch schon IsNan() aus dem Modul BRL.Math, oder?
Gewinner der 6. und der 68. BlitzCodeCompo
 

sinjin

BeitragFr, Apr 03, 2020 20:30
Antworten mit Zitat
Benutzer-Profile anzeigen
Oh stimmt, ist ja auch noch nicht allzu lange in BRL.Math. Dafür fängt meine Funktion auch alle negativen Fälle ab, zB. gibt ISINF nur 1 oder null wieder, nie -1. Dabei ist #INF nicht unbedingt eine Exception, man kann damit weiterrechnen, gibt halt nur immer Unendlich.

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group