]> www.ginac.de Git - cln.git/blob - src/float/sfloat/misc/cl_SF_idecode.cc
a3b59a5dea22ad78a0f0f7e3d4abe5bdc58764d1
[cln.git] / src / float / sfloat / misc / cl_SF_idecode.cc
1 // integer_decode_float().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_sfloat.h"
8
9
10 // Implementation.
11
12 #include "cl_SF.h"
13 #include "cl_I.h"
14
15 MAYBE_INLINE
16 const cl_idecoded_float integer_decode_float (const cl_SF& x)
17 {
18         // x entpacken:
19         var cl_signean sign;
20         var sintL exp;
21         var uint32 mant;
22         SF_decode(x, { return cl_idecoded_float(0, 0, 1); },
23                      sign=,exp=,mant=
24                  );
25         return cl_idecoded_float(
26                 L_to_FN(mant), // Mantisse als Fixnum (>0, <2^17)
27                 L_to_FN(exp-(SF_mant_len+1)), // e-17 als Fixnum
28                 (sign>=0 ? cl_I(1) : cl_I(-1)) // (-1)^s erzeugen
29                );
30 }