9.2.18 __fpnormalize Function

A function that normalizes a floating-point value.

Include

<xc.h>

Prototype

__fpnormalize(double value);

value
The floating-point value to normalize

Remarks

This function can be used to ensure that an arbitrary 32-bit floating-point value (which is not the result of a calculation performed by the compiler) conforms to the "relaxed" floating-point rules (as described in Section 4.4.4 “Floating-Point Data Types”).

This function returns the value passed to it, but ensures that any subnormal argument is flushed to zero, and converts any negative zero argument to a positive zero result.

Example

#include <xc.h>

int main(void)
{
  double input_fp;
  // read in a floating-point value from an external source
  input_fp = getFP();
  // ensure it is formatted using the relaxed rules
  input_fp = __fpnormalize(input_fp);
}