Cg Toolkit Cg 3.1 Toolkit Documentation

Name

frexp - splits scalars and vectors into normalized fraction and a power of 2

Synopsis

float  frexp(float x, out float e);
float1 frexp(float1 x, out float1 e);
float2 frexp(float2 x, out float2 e);
float3 frexp(float3 x, out float3 e);
float4 frexp(float4 x, out float4 e);

half   frexp(half x, out half e);
half1  frexp(half1 x, out half1 e);
half2  frexp(half2 x, out half2 e);
half3  frexp(half3 x, out half3 e);
half4  frexp(half4 x, out half4 e);

fixed  frexp(fixed x, out fixed e);
fixed1 frexp(fixed1 x, out fixed1 e);
fixed2 frexp(fixed2 x, out fixed2 e);
fixed3 frexp(fixed3 x, out fixed3 e);
fixed4 frexp(fixed4 x, out fixed4 e);

Parameters

x
Vector or scalar of which to split.
e
Vector or scalar where the exponent of x is output.

Description

This function decomposes x into two parts: a mantissa between 0.5 and 1 (returned by the function) and an exponent output as e.

If the value x is zero, both parts of the result are zero.

For vectors, the returned vector contains the mantissa of each element of the input vector and the output vector contains the exponent of each element of the input vector.

Reference Implementation

The example below is not legal Cg because it uses the & address-of operator not supported by Cg in order to call the ANSI C frexp routine.

float3 frexp(float3 x, out float3 e)
{
  float3 rv;
  int i;

  for (i=0; i<3; i++) {
    float eout;

    rv[i] = frexp(a[i], &eout);  // this is the ANSI C standard library frexp()
    e[i] = eout;
  }
  return rv;
}

Profile Support

frexp is fully supported in all profiles unless otherwise specified.

Support in the fp20 is limited to constant compile-time evaluation.

See Also

exp2, log, pow


Cg Toolkit | Cg Toolkit | Download | Release Archive | Profiles | Reference | Books | Discussions |


Cg Standard Library

abs
acos
all
any
asin
atan2
atan
bitCount
bitfieldExtract
bitfieldInsert
bitfieldReverse
ceil
clamp
clip
cosh
cos
cross
ddx
ddy
degrees
determinant
distance
dot
exp2
exp
faceforward
findLSB
findMSB
floatToIntBits
floatToRawIntBits
floor
fmod
frac
frexp
fwidth
intBitsToFloat
inverse
isfinite
isinf
isnan
ldexp
length
lerp
lit
log10
log2
log
max
min
modf
mul
normalize
pack
pow
radians
reflect
refract
round
rsqrt
saturate
sign
sincos
sinh
sin
smoothstep
sqrt
step
tanh
tan
tex1DARRAYbias
tex1DARRAYcmpbias
tex1DARRAYcmplod
tex1DARRAYfetch
tex1DARRAYlod
tex1DARRAY
tex1DARRAYproj
tex1DARRAYsize
tex1Dbias
tex1Dcmpbias
tex1Dcmplod
tex1Dfetch
tex1Dlod
tex1D
tex1Dproj
tex1Dsize
tex2DARRAYbias
tex2DARRAYfetch
tex2DARRAYlod
tex2DARRAY
tex2DARRAYproj
tex2DARRAYsize
tex2Dbias
tex2Dcmpbias
tex2Dcmplod
tex2Dfetch
tex2Dlod
tex2DMSARRAYfetch
tex2DMSARRAYsize
tex2DMSfetch
tex2DMSsize
tex2D
tex2Dproj
tex2Dsize
tex3Dbias
tex3Dfetch
tex3Dlod
tex3D
tex3Dproj
tex3Dsize
texBUF
texBUFsize
texCUBEARRAYbias
texCUBEARRAYlod
texCUBEARRAY
texCUBEARRAYsize
texCUBEbias
texCUBElod
texCUBE
texCUBEproj
texCUBEsize
texRBUF
texRBUFsize
texRECTbias
texRECTfetch
texRECTlod
texRECT
texRECTproj
texRECTsize
transpose
trunc
unpack