NAME

floatToRawIntBits - returns the raw 32-bit integer representation of an IEEE 754 floating-point scalar or vector

SYNOPSIS

  int  floatToRawIntBits(float  x);
  int1 floatToRawIntBits(float1 x);
  int2 floatToRawIntBits(float2 x);
  int3 floatToRawIntBits(float3 x);
  int4 floatToRawIntBits(float4 x);
 

PARAMETERS

x

Floating-point vector or scalar to raw cast to a scalar int or vector of ints.

DESCRIPTION

Returns a representation of the specified floating-point scalar value or vector values according to the IEEE 754 floating-point "single format" bit layout, preserving Not-a-Number (NaN) values.

This function is based on Java's jave.lang.Float method of the same name. See:

  java.sun.com/j2se/1.4.2/docs/api/java/lang/Float.html

The Cg compiler can typically optimize floatToRawIntBits so it has no instruction cost.

REFERENCE IMPLEMENTATION

floatToRawIntBits operates consistent with the following ANSI C code:

  int floatToRawIntBits(float  x)
  {
    union {
      float f;  // assuming 32-bit IEEE 754 single-precision
      int i;    // assuming 32-bit 2's complement int
    } u;

    u.f = x;
    return u.i;
  }

PROFILE SUPPORT

floatToRawIntBits is supported by the gp4vp, gp4gp, and gp4vp profiles.

floatToRawIntBits is not supported by pre-G80 profiles.

SEE ALSO

ceil, floatToIntBits, floor, intBitsToFloat, round, trunc