Project

General

Profile

Feature #553

Port function MantissaAndExponent2

Added by Anna Maria Bigatti almost 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
CoCoA-5 function: new
Target version:
Start date:
12 May 2014
Due date:
% Done:

100%

Estimated time:
4.00 h
Spent time:

Description

MantissaAndExponent2 is defined in CoCoALib and mentioned in the manual for CoCoA-5.
Porting it to CoCoA-5 should be easy (copying MantissaAndExponent10)

History

#1 Updated by John Abbott almost 10 years ago

  • Status changed from New to In Progress
  • Assignee set to John Abbott
  • % Done changed from 0 to 30

I've just copied the code for MantissaAndExponent10 -- it seems a waste writing code using cut-and-paste :-(

Added the missing entry to the C5 manual.

There is an inconsistency:
MantExp10(0.5,3) produces Record[exp:=-1, mant:=500]
so the value represented is 10^(exp)*mant/10^(numdigits)

MantExp2(0.5,8) produces Record[exp:=-8, mant:=128]
so the value represented is 2^(exp)*mant

Which approach is better?

#2 Updated by Anna Maria Bigatti almost 10 years ago

John Abbott wrote:

I've just copied the code for MantissaAndExponent10 -- it seems a waste writing code using cut-and-paste :-(

Added the missing entry to the C5 manual.

There is an inconsistency:
MantExp10(0.5,3) produces Record[exp:=-1, mant:=500]
so the value represented is 10^(exp)*mant/10^(numdigits)

MantExp2(0.5,8) produces Record[exp:=-8, mant:=128]
so the value represented is 2^(exp)*mant

Which approach is better?

I'd like to have Record[exp:=-1, mant:=500, NumDigits:=3]
even though it is a bit redundant.
exp:=-1 is the most meaningful information, so it would be a bit odd to have it depending on the number of digits.
On the other hand a direct interpretation of the result, as in the second case, is nice. So it would be nice to give the extra information about numdigits without having to compute a logarithm.

#3 Updated by Anna Maria Bigatti almost 10 years ago

For JAA: commit file for fixing
BuiltInFunctions.C:678: error: 'class CoCoA::MantExp2' has no member named 'myNumDigits'

12:52 DONE!

#4 Updated by John Abbott almost 10 years ago

  • Status changed from In Progress to Feedback
  • % Done changed from 30 to 90
  • Estimated time set to 4.00 h

I have implemented, tested, & documented.

I followed Anna's suggestion: a MantExp2 structure now contains 4 (public) fields
  • mySign
  • myExponent
  • myMantissa
  • myNumDigits

The value represented is mySign * myMantissa * 2^(myExponent-myNumDigits+1)

Similarly for MantExp10

#5 Updated by John Abbott over 9 years ago

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

Also available in: Atom PDF