diff options
author | Lukas Larsson <[email protected]> | 2011-08-08 16:13:32 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-10-11 17:19:00 +0200 |
commit | 6c1a36a91a0b214d598f845bed2b649a4de8ae3f (patch) | |
tree | 3214c519e5a3782d14c13741884598876cfe8ce6 /erts/emulator/beam/big.c | |
parent | f99fd21debc8274dbdecd595e1666436ec962ccd (diff) | |
download | otp-6c1a36a91a0b214d598f845bed2b649a4de8ae3f.tar.gz otp-6c1a36a91a0b214d598f845bed2b649a4de8ae3f.tar.bz2 otp-6c1a36a91a0b214d598f845bed2b649a4de8ae3f.zip |
Cleanup double_to_bignum conversion code
Diffstat (limited to 'erts/emulator/beam/big.c')
-rw-r--r-- | erts/emulator/beam/big.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/erts/emulator/beam/big.c b/erts/emulator/beam/big.c index 51e5d2d305..b90ea6b478 100644 --- a/erts/emulator/beam/big.c +++ b/erts/emulator/beam/big.c @@ -1584,23 +1584,22 @@ big_to_double(Wterm x, double* resp) return 0; } +/* + * Logic has been copied from erl_bif_guard.c and slightly + * modified to use a static instead of dynamic heap + */ Eterm double_to_big(double x, Eterm *heap) { int is_negative; int ds; ErtsDigit* xp; - Eterm tmp_res; + Eterm res; int i; size_t sz; Eterm* hp; double dbase; - if ((x < (double) (MAX_SMALL + 1)) && (x > (double) (MIN_SMALL - 1))) { - Sint xi = x; - return make_small(xi); - } - if (x >= 0) { is_negative = 0; } else { @@ -1618,7 +1617,7 @@ double_to_big(double x, Eterm *heap) sz = BIG_NEED_SIZE(ds); /* number of words including arity */ hp = heap; - tmp_res = make_big(hp); + res = make_big(hp); xp = (ErtsDigit*) (hp + 1); for (i = ds - 1; i >= 0; i--) { @@ -1638,7 +1637,7 @@ double_to_big(double x, Eterm *heap) } else { *hp = make_pos_bignum_header(sz-1); } - return tmp_res; + return res; } |