Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
ulp.c File Reference
#include "gdtoaimp.h"
Include dependency graph for ulp.c:

Go to the source code of this file.

Functions

double ulp (double x)
 

Function Documentation

◆ ulp()

double ulp ( double  x)

Definition at line 38 of file ulp.c.

40 {
41  Long L;
42  double a;
43 
44  L = (word0(x) & Exp_mask) - (P - 1) * Exp_msk1;
45 #ifndef Sudden_Underflow
46  if(L > 0)
47  {
48 #endif
49 #ifdef IBM
50  L |= Exp_msk1 >> 4;
51 #endif
52  word0(a) = (ULong)L;
53  word1(a) = 0;
54 #ifndef Sudden_Underflow
55  }
56  else
57  {
58  L = -L >> Exp_shift;
59  if(L < Exp_shift)
60  {
61  word0(a) = 0x80000 >> L;
62  word1(a) = 0;
63  }
64  else
65  {
66  word0(a) = 0;
67  L -= Exp_shift;
68  word1(a) = L >= 31 ? 1 : 1 << (31 - L);
69  }
70  }
71 #endif
72  return a;
73 }
#define P
Definition: gdtoaimp.h:399
#define Exp_msk1
Definition: gdtoaimp.h:396
#define word1(x)
Definition: gdtoaimp.h:305
#define word0(x)
Definition: gdtoaimp.h:304
unsigned Long ULong
Definition: gdtoa.h:41
#define Exp_mask
Definition: gdtoaimp.h:398
#define Exp_shift
Definition: gdtoaimp.h:394
#define Long
Definition: gdtoa.h:38

References Exp_mask, Exp_msk1, Exp_shift, Long, P, word0, and word1.

Referenced by strtod(), strtodI(), and ulpdown().