[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[task #16114] Print warning where integer overflow happens
From: |
Pedram Ashofteh Ardakani |
Subject: |
[task #16114] Print warning where integer overflow happens |
Date: |
Tue, 1 Feb 2022 05:31:20 -0500 (EST) |
URL:
<https://savannah.gnu.org/task/?16114>
Summary: Print warning where integer overflow happens
Project: GNU Astronomy Utilities
Submitted by: pedram
Submitted on: Tue 01 Feb 2022 10:31:18 AM UTC
Should Start On: Tue 01 Feb 2022 12:00:00 AM UTC
Should be Finished on: Tue 01 Feb 2022 12:00:00 AM UTC
Category: Arithmetic
Priority: 5 - Normal
Item Group: Enhancement
Status: None
Privacy: Public
Percent Complete: 0%
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Effort: 0.00
_______________________________________________________
Details:
As explained in bug #61969 , arithmetic reads inputs and uses the smallest
numerical data type possible to compute more efficiently with the least amount
of memory. However, the user might not be aware of the *integer overflow* that
might happen when calculations result in values that need larger storage
types. For example:
$ astarithmetic 254 2 +
0
This happens because _254_ and _2_ are both of type _uint8_ that can store a
maximum value of 255, so instead of getting the expected result _256_, we'd
get _0_ as the result of an integer overflow. One way to work around this for
now is to use floating points in the inputs, for instance:
$ astarithmetic 254.0 2 +
256
Since this is happening silently, we need to at least print a warning to
notify the user of the circumstances. So this task is defined here as Mohammad
pointed out in bug #61969:
> C library's 'errno.h' has a special error code for such range overflows:
'ERANGE'. We should add a check for this error code within arithmetic and if
it happens, a warning should be printed that an overflow has happened (to
standard-error; so its even printed with '--quiet'!).
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/task/?16114>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [task #16114] Print warning where integer overflow happens,
Pedram Ashofteh Ardakani <=