Project

General

Profile

Feature #856

MantissaAndExponent2 for twin-float

Added by John Abbott about 8 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
New Function
Start date:
25 Mar 2016
Due date:
% Done:

100%

Estimated time:
4.01 h
Spent time:

Description

So far the only way to get a "proper value" out of a twin-float was to use IsRational, but that works only if the value is a simple rational - it does not work if the twin-float is an approximation to sqrt(2), say.

A MantExp2 structure is a good way of representing a finite precision approximation, so it makes sense to "export" a twin-float into a MantExp2 structure.

Implement!

History

#1 Updated by John Abbott about 8 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Here is a summary description of the ideal behaviour of the "exporting" fn:
let x be a (non-zero) twin-float (zero is trivial to deal with);
let ME2 be the corresponding MantExp2 structure;
let Q be the exact rational corresponding to the exact value of ME2;
let Q_up and Q_down be the rationals corresponding the values of MantExp2 structures whose only difference is that the "mantissa" part has been incremented (or decremented) by 1;
then I would like @Q_up > x
to give true, and Q_down < x to give true.
I'm not sure if it is reasonable to expect Q == x to give true (rather than InsuffPrec); I would certainly hope it does not give false!

#2 Updated by John Abbott about 8 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 10 to 90

I have implemented the fn. It seems to work more or less as expected.

Note that the fn does reveal some of what goes on inside twin-float arithmetic, so it is quite likely that the same computation performed twice may give slightly different results when MantissaAndExponent2 is applied.

I do not think that MantissaAndExponent10 makes sense here.

Documented.
Exported to CoCoA-5, and documented there too.

#3 Updated by John Abbott over 7 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100

Closing after 6 months in feedback.

#4 Updated by Anna Maria Bigatti almost 7 years ago

  • Estimated time set to 4.01 h

Also available in: Atom PDF