Why does bfloat behave this way?



On 2013-11-02, Igor Korepanov <paloff at ya.ru> wrote:

> Now the question: why does bfloat behave exactly this way? And not some other way?

You might get a more direct, precise answer if you explicitly state what
you mean by "this way", and what you expected to see. Just a guess.

> (%i2) fpprec: 300;
> (%o2) 300
>
> (%i3) x: bfloat( 3.4567890123 );
> bfloat: converting float 3.4567890123 to bigfloat.
> (%o3) 3.45678901229999979705098667182028293609619140625b0

Note that x : bfloat(nnnn.nnn) creates a float first and then makes a
bigfloat from that. That's something different from nnnn.nnnb0 which
constructs a bigfloat directly. Try nnnn.nnnb0 - bfloat(nnnn.nnn) --
I think you'll find there's a difference which is related to the
precision of IEEE 754 double floats.

best

Robert Dodier