frexp

Autres langues

Langue: fr

Version: 30 juillet 2003 (openSuse - 09/10/07)

Section: 3 (Bibliothèques de fonctions)

NOM

frexp, frexpf, frexpl - Conversion de réel en fraction normalisée.

SYNOPSIS


#include <math.h>



double frexp (double x, int *exp);



float frexpf (float x, int *exp);



long double frexpl (long double x, int *exp);

DESCRIPTION

La fonction frexp() est utilisée pour scinder le nombre x en une fraction normalisée et un exposant qui est stocké dans exp.

VALEUR RENVOYÉE

La fonction frexp() renvoie la fraction normalisée.

Si x est non nul, x est égale à la fraction renvoyée multiplié par 2^exp. La fraction est dans l'intervalle [1/2, 1[.

Si x est nul, la fraction normalisée vaut zéro et exp également.

EXEMPLE


#include <math.h>

#include <stdio.h>



int

main (void)

{

   float x, f;

   int ex;

   while (1) {

      fscanf (stdin, "%f", & x);

      f = frexp (x, & ex);

      fprintf (stdout,"%f = %f x 2^%d\n", x, f, ex);

   }

   return (0);

}



$ ./a.out 



0

0.000000 = 0.000000 x 2^0

1

1.000000 = 0.500000 x 2^1

2

2.000000 = 0.500000 x 2^2

3

3.000000 = 0.750000 x 2^2

4

4.000000 = 0.500000 x 2^3

5

5.000000 = 0.625000 x 2^3



$ 



CONFORMITÉ

SVID 3, POSIX, BSD 4.3, ISO 9899

VOIR AUSSI

ldexp(3), modf(3)

TRADUCTION

Christophe Blaess, 1996-2003.