fixes #172
This commit is contained in:
parent
b5a44481f9
commit
39f399f424
2 changed files with 7 additions and 7 deletions
|
|
@ -524,7 +524,7 @@ proc unaryArith(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||||
"(($3)(NU32)(NU64)($1))", # ToU32
|
"(($3)(NU32)(NU64)($1))", # ToU32
|
||||||
"((double) ($1))", # ToFloat
|
"((double) ($1))", # ToFloat
|
||||||
"((double) ($1))", # ToBiggestFloat
|
"((double) ($1))", # ToBiggestFloat
|
||||||
"float64ToInt32($1)", # ToInt XXX: this is not correct!
|
"float64ToInt32($1)", # ToInt
|
||||||
"float64ToInt64($1)"] # ToBiggestInt
|
"float64ToInt64($1)"] # ToBiggestInt
|
||||||
var
|
var
|
||||||
a: TLoc
|
a: TLoc
|
||||||
|
|
|
||||||
|
|
@ -352,14 +352,14 @@ typedef char* NCSTRING;
|
||||||
# define NIM_IMAN 0
|
# define NIM_IMAN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static N_INLINE(NI32, float64ToInt32)(double val) {
|
static N_INLINE(NI, float64ToInt32)(double x) {
|
||||||
val = val + 68719476736.0*1.5;
|
/* nowadays no hack necessary anymore */
|
||||||
/* 2^36 * 1.5, (52-_shiftamt=36) uses limited precisicion to floor */
|
return x >= 0 ? (NI)(x+0.5) : (NI)(x-0.5);
|
||||||
return ((NI32*)&val)[NIM_IMAN] >> 16; /* 16.16 fixed point representation */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static N_INLINE(NI32, float32ToInt32)(float val) {
|
static N_INLINE(NI32, float32ToInt32)(float x) {
|
||||||
return float64ToInt32((double)val);
|
/* nowadays no hack necessary anymore */
|
||||||
|
return x >= 0 ? (NI32)(x+0.5) : (NI32)(x-0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define float64ToInt64(x) ((NI64) (x))
|
#define float64ToInt64(x) ((NI64) (x))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue