Skip to content

fix maxima floating point precision handling #1286

@williamstein

Description

@williamstein

This sucks:

sage: SR(1.93902384092834082309480238482348293402384908) + SR(1)
2.939023840928341

It should do this:

sage: SR(1.93902384092834082309480238482348293402384908) + SR(1)
2.93902384092834082309480238482348293402384908

How to implement this? Use bfloat in Maxima. Here are some examples:

(%i41) block([fpprec:50], bfloat(%pi));
(%o41)       3.1415926535897932384626433832795028841971693993751b0

Have to do some weird crap to coerce in mpfr's:

(%i1) block([fpprec:50], bfloat(1.93902384092834082309480238482348293402384908));
Warning:  Float to bigfloat conversion of 1.939023840928341
(%o1)        1.9390238409283409299344632850674846197472777518007b0
(%i3) block([fpprec:50], bfloat(193902384092834082309480238482348293402384908)/10^44);
(%o3)          1.93902384092834082309480238482348293402384908b0

When simplifying an expression be sure to compute the prec of it as
the min of the precs of all the leaves; integers have infinite precision.

Component: calculus

Issue created by migration from https://trac.sagemath.org/ticket/1286

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions