On Friday, 9 June 2017 at 16:56:46 UTC, ketmar wrote:
Petar Kirov [ZombineDev] wrote:
Do HexFloats (http://dlang.org/spec/lex#HexFloat) help?
hm. i somehow completely missed "%a" format specifier! yeah,
"-0x1.6ep-3" did the trick.
tnx. i should do my homework *before* posting big rants
On Friday, 9 June 2017 at 17:25:22 UTC, ketmar wrote:
it is highly platform-dependent. and both bin->dec, and
dec->bin conversion routines can contain errors, btw. so using
decimal forms for exact bit-patterns is the last thing i want
to do, as i know how fragile they are.
Sure. Hex-format is
Honey wrote:
On Friday, 9 June 2017 at 16:34:28 UTC, ketmar wrote:
Try -0.1685f.
it doesn't matter if i can find the decimal representation for the given
bit pattern or not. the whole post is about removing the need to rely on
lossy binary->decimal->binary conversions.
Lossless turn-a
Basile B. wrote:
On Friday, 9 June 2017 at 17:18:43 UTC, ketmar wrote:
Basile B. wrote:
enum binFloat = *cast(float*) &b;
i was SO sure that this won't work in CTFE that i didn't even tried to
do it. "it will fail anyway, there is no reason in trying!" ;-)
You can do the arithmetic
On Friday, 9 June 2017 at 17:18:43 UTC, ketmar wrote:
Basile B. wrote:
enum binFloat = *cast(float*) &b;
i was SO sure that this won't work in CTFE that i didn't even
tried to do it. "it will fail anyway, there is no reason in
trying!" ;-)
You can do the arithmetic as well. I don't k
Basile B. wrote:
enum binFloat = *cast(float*) &b;
i was SO sure that this won't work in CTFE that i didn't even tried to do
it. "it will fail anyway, there is no reason in trying!" ;-)
On Friday, 9 June 2017 at 16:42:31 UTC, ketmar wrote:
Basile B. wrote:
Yes, easy to do, a template alĂ octal or hexString.
can you show it, please? remember, CTFE-able!
Sure, here's a dirty draft:
template binFloat(string sign, string exp, string mant)
{
enum s = sign == "+" ? "0" : "1"
Petar Kirov [ZombineDev] wrote:
Do HexFloats (http://dlang.org/spec/lex#HexFloat) help?
hm. i somehow completely missed "%a" format specifier! yeah,
"-0x1.6ep-3" did the trick.
tnx. i should do my homework *before* posting big rants, lol.
On Friday, 9 June 2017 at 16:41:01 UTC, Honey wrote:
Lossless turn-around is guaranteed if you are using
sufficiently many digits. In case of IEEE-754 single precision
it's 8 significant decimal digits.
s/turn-around/recovery/g
s/8/9/g
:-P
On Friday, 9 June 2017 at 16:07:36 UTC, ketmar wrote:
let's say that i have precomputed some `float`-typed tables,
and now i want to use 'em in my code. for example, a table for
Lagrange series. the table itself is like 10 numbers, but the
code calculating it rather big, and it depends of archi
Basile B. wrote:
ps. "-0.17 0xBE2AAAC1". it's not the same! (and yes, it matters).
-0.17f is not representable as a 32 bit float. The actuall value
that's stored is -0.169994592259765625, hence the difference. See
https://www.h-schmidt.net/FloatConverter/IEEE754.html and
On Friday, 9 June 2017 at 16:34:28 UTC, ketmar wrote:
Try -0.1685f.
it doesn't matter if i can find the decimal representation for
the given bit pattern or not. the whole post is about removing
the need to rely on lossy binary->decimal->binary conversions.
Lossless turn-around is guaran
On Friday, 9 June 2017 at 16:07:36 UTC, ketmar wrote:
let's say that i have precomputed some `float`-typed tables,
and now i want to use 'em in my code. for example, a table for
Lagrange series. the table itself is like 10 numbers, but the
code calculating it rather big, and it depends of archi
Honey wrote:
On Friday, 9 June 2017 at 16:07:36 UTC, ketmar wrote:
one of my calculated values is `-0.17`, which has bit-pattern of
0xBE2AAAB7.
now, let's say i want to use this number in my code:
float v = -0.17f;
writefln("%f 0x%08X", v, *cast(uint*)&v);
ps. "-0
On Friday, 9 June 2017 at 16:07:36 UTC, ketmar wrote:
one of my calculated values is `-0.17`, which has
bit-pattern of 0xBE2AAAB7.
now, let's say i want to use this number in my code:
float v = -0.17f;
writefln("%f 0x%08X", v, *cast(uint*)&v);
ps. "-0.17 0xBE2AA
let's say that i have precomputed some `float`-typed tables, and now i want
to use 'em in my code. for example, a table for Lagrange series. the table
itself is like 10 numbers, but the code calculating it rather big, and it
depends of architecture (so it can yield different results on different
16 matches
Mail list logo