remove strict alias warning...

master
sanjiyan 21 years ago
parent a58d400d5c
commit 8f66476e0d

@ -1,10 +1,13 @@
#include "fmt.h" #include "fmt.h"
unsigned int fmt_double(char *dest, double d,int maxlen,int prec) { unsigned int fmt_double(char *dest, double d,int maxlen,int prec) {
unsigned long long *x=(unsigned long long *)&d; union {
double d;
unsigned long long x;
} __u = { .d=d, };
/* step 1: extract sign, mantissa and exponent */ /* step 1: extract sign, mantissa and exponent */
signed int s=*x>>63; signed int s=__u.x>>63;
signed long e=((*x>>52)&((1<<11)-1))-1023; signed long e=((__u.x>>52)&((1<<11)-1))-1023;
/* unsigned long long m=*x & ((1ull<<52)-1); */ /* unsigned long long m=*x & ((1ull<<52)-1); */
/* step 2: exponent is base 2, compute exponent for base 10 */ /* step 2: exponent is base 2, compute exponent for base 10 */
signed long e10=1+(long)(e*0.30102999566398119802); /* log10(2) */ signed long e10=1+(long)(e*0.30102999566398119802); /* log10(2) */

Loading…
Cancel
Save