Project

General

Profile

Design #1547

Require decimal mode for ostream?

Added by John Abbott over 3 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Safety
Target version:
Start date:
05 Dec 2020
Due date:
% Done:

100%

Estimated time:
0.70 h
Spent time:

Description

In issue #1529 we have decided to require that when reading from an istream the stream must be in decimal mode.
Should we require the same for writing to an ostream?

If so, maybe we should supply a function which converts an integer (or rational?) to a string using the given base?


Related issues

Related to CoCoALib - Design #1529: INPUT questionsClosed2020-10-31

History

#1 Updated by John Abbott over 3 years ago

#2 Updated by John Abbott about 3 years ago

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

I do not like the idea of converting a BigInt or BigRat to a non-decimal string via normal output operators.
[We could produce an explicit fn which does convert BigInt or BigRat to a string using a given base]

I suggest using assertions to check that ostream is in decimal mode; or possibly print out a warning?
It could be surprising to the user/programmer if printing can cause an error.

#3 Updated by John Abbott about 3 years ago

  • Status changed from In Progress to Resolved
  • Assignee set to John Abbott
  • % Done changed from 10 to 70

I have now added assertions to printing for BigInt, BigRat (which anyway prints a BigInt), PPMonoidElem, and finite fields.
That should cover virtually all cases!

PS: and symbol

#4 Updated by John Abbott about 3 years ago

  • Status changed from Resolved to Feedback
  • % Done changed from 70 to 90

I have changed most/all output fns so that they assert that the ostream is in decimal mode.
Contrast with input fns which give error is istream is not in decimal mode.

It is possible that some minor output fns have been skipped... probably not so important.

#5 Updated by John Abbott about 2 years ago

  • Status changed from Feedback to Closed
  • % Done changed from 90 to 100
  • Estimated time set to 0.70 h

Also available in: Atom PDF