• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [ANN] Value Converter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ANN] Value Converter


  • Subject: Re: [ANN] Value Converter
  • From: Darrin Cardani <email@hidden>
  • Date: Sun, 28 Nov 2004 10:00:13 -0600

At 6:16 AM -0800 11/28/04, Shaun Wexler <email@hidden> wrote:
#include <std_disclaimer.h> // written in Mail.app

extern float *theFloat;

int float32i = *(int *)theFloat;
int exponent = ((float32i & 0x7f800000) >> 23) - 127;
int mantissa = float32i & 0x007fffff;
int sign = float32i >> 31;
BOOL isNegative = (sign == 1);
BOOL isDenormal = (exponent == 0 && mantissa != 0);
BOOL isInfinity = (exponent == 128 && mantissa == 0));
BOOL isNan = (exponent == 128 && mantissa != 0);
BOOL isQNan = isNan && (mantissa & 0x00400000 != 0);

You can also use fpclassify () from the standard <cmath> header. It will return the standard constants FP_NORMAL, FP_NAN, FP_INFINITE, FP_ZERO, and FP_SUBNORMAL. (I don't see anything about QNan, though.) Writing it that way may make it easier to keep working on later or alternate OSes. It also has a macro for getting the sign bit, called signbit ().


Darrin
--
Darrin Cardani - email@hidden
President, Buena Software, Inc.
<http://www.buena.com/>
Video, Image and Audio Processing Development
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Nib files and outlets
  • Next by Date: Re: Nib files and outlets
  • Previous by thread: Re: [ANN] Value Converter
  • Next by thread: setAutoresizingMask help
  • Index(es):
    • Date
    • Thread