[PD] denormalized numbers bugfix in PD

Olaf Matthes olaf.matthes at gmx.de
Fri Sep 19 12:53:25 CEST 2003


Krzysztof Czaja schrieb:
> Does anybody know, how to modify it without a performance loss?

Here is what Max/MSP (Windows) uses:

#define IS_DENORM_FLOAT(v)              ((((*(unsigned long
*)&(v))&0x7f800000)==0)&&((v)!=0.f))
#define IS_DENORM_DOUBLE(v)             ((((((unsigned long
*)&(v))[1])&0x7fe00000)==0)&&((v)!=0.))                 

#define IS_NAN_FLOAT(v)                 (((*(unsigned long
*)&(v))&0x7f800000)==0x7f800000)
#define IS_NAN_DOUBLE(v)                (((((unsigned long
*)&(v))[1])&0x7fe00000)==0x7fe00000)

#define IS_DENORM_NAN_FLOAT(v)         
(IS_DENORM_FLOAT(v)||IS_NAN_FLOAT(v))
#define IS_DENORM_NAN_DOUBLE(v)        
(IS_DENORM_DOUBLE(v)||IS_NAN_DOUBLE(v))                 

#define FIX_DENORM_FLOAT(v)             ((v)=IS_DENORM_FLOAT(v)?0.f:(v))
#define FIX_DENORM_DOUBLE(v)           
((v)=IS_DENORM_DOUBLE(v)?0.f:(v))

#define FIX_DENORM_NAN_FLOAT(v)        
((v)=IS_DENORM_NAN_FLOAT(v)?0.f:(v))
#define FIX_DENORM_NAN_DOUBLE(v)       
((v)=IS_DENORM_NAN_DOUBLE(v)?0.:(v))




More information about the Pd-list mailing list