Report 1602 Actions
Problem Report Number |
1602 |
Submitter's Classification |
Test Suite problem |
State |
Resolved |
Resolution |
Permanent Interpretation (PIN) |
Problem Resolution ID |
PIN.X.0159 |
Raised |
1995-02-27 08:00 |
Updated |
2003-03-13 08:00 |
Published |
1996-04-01 08:00 |
Product Standard |
Internationalised System Calls and Libraries Extended (UNIX 95) |
Certification Program |
The Open Brand certification program |
Test Suite |
VSU version 4.1.0 |
Test Identification |
CAPI.os/genuts/ecvt 4 |
Specification |
System Interfaces and Libraries Issue 4 Version 2 |
Location in Spec |
See Problem Text |
Problem Summary |
PIN4U.00025 This IR claims that rounding -1.5 to -2 should be allowed. |
Problem Text |
This IR claims that rounding -1.5 to -2 should be allowed.
Apparently the test case expects that -1.5 should be rounded up and that if you are rounding up a negative number, then -1.5 would round up to -1, since -1 is larger than -1.5. I think the wrong rules for rounding are being used. It is true if you are talking about the "ceiling" or "floor" of a negative number. In that case if you are rounding up (ceiling) -1.5, then you would get -1 and not -2. But this is not the formula for rounding a number. If you were rounding to the nearest whole number, for example, -1.5 would round to -2. This rule works in the same direction as rounding to the next nearest digit (rounding to the NSth). That is different from "ceiling" or "floor" and independent of the floating point rounding mode implemented on the machine. I tried this on several interpreters and compilers (where rounding the wrong way would not go unnoticed) and found that -1.55 rounded to -1.6 and not -1.5. For any positive or negative scale point, Ns, I want to "round" all real numbers on interval (s/2-abs(Ns)+s/2) to Ns; where N is any integer and s is the scaling factor. For the best reference please lookup "rounding to the nearest NSth."
|
Test Output |
------------------------------------------------------------------------ 200|0 4 13:20:54|TP Start 520|0 4 589828 1 1|SPEC1170TESTSUITE CASE 4 520|0 4 589828 1 2|The low order digit of the string returned by a call 520|0 4 589828 1 3|to char *ecvt(double value, int ndigit, 520|0 4 589828 1 4|int *decpt, int *sign) shall be rounded. 520|0 4 35258381 1 1|TEST: ecvt(0.000000, 1) should return 0 520|0 4 35258381 1 2|TEST: ecvt(1290000.000000, 3) should return 129 520|0 4 35258381 1 3|TEST: ecvt(1290000.000000, 2) should return 13 520|0 4 35258381 1 4|TEST: ecvt(1290000.000000, 1) should return 1 520|0 4 35258381 1 5|TEST: ecvt(19999999999.000000, 8) should return 20000000 520|0 4 35258381 1 6|TEST: ecvt(19999990999.000000, 8) should return 19999991 520|0 4 35258381 1 7|TEST: ecvt(15.499900, 3) should return 155 520|0 4 35258381 1 8|TEST: ecvt(-2284.347840, 6) should return 228435 520|0 4 35258381 1 9|TEST: ecvt(-38.293900, 7) should return 3829390 520|0 4 35258381 1 10|TEST: ecvt(123.450000, 10) should return 1234500000 520|0 4 35258381 1 11|TEST: ecvt(-123.450000, 3) should return 123 520|0 4 35258381 1 12|TEST: ecvt(12345.987200, 8) should return 12345997 520|0 4 35258381 1 13|TEST: ecvt(12345.987300, 8) should return 12345987 520|0 4 35258381 1 14|TEST: ecvt(0.123460, 8) should return 12345987 520|0 4 35258381 1 15|TEST: ecvt(0.012346, 8) should return 12345988 520|0 4 35258381 1 16|TEST: ecvt(-12345.987500, 8) should return 12345987 520|0 4 35258381 1 17|ERROR: Low order digit is incorrect, expected 12345987, re ceived 12345988 220|0 4 1 13:20:54|FAIL
|
Review Information
Review Type |
TSMA Review |
Start Date |
null |
Completed |
null |
Status |
Complete |
Review Recommendation |
No Resolution Given |
Review Response |
We recommend this request be refused.
We believe the test is correct.
The value, 1.5, is equidistant between 1 and 2. When 1.5 is rounded, it is rounded to 2, the next greater number. The same applies to -1.5. It is equidistant between -2 and -1. The same rounding rule is applied, and it is rounded to -1, the next greater number.
The references to floor() and ceil() do not apply, because those functions do not deal with rounding behavior.
Although behavior of specific implementaitons is not normative, all implementations we have checked PASS this test.
|
Review Type |
Expert Group Review |
Start Date |
null |
Completed |
null |
Status |
Complete |
Review Resolution |
No Resolution Given |
Review Conclusion |
This is a grey area as the specification does not define rounding. A Permanent Interpretation should be granted.
|
Review Type |
SA Review |
Start Date |
null |
Completed |
null |
Status |
Complete |
Review Resolution |
Permanent Interpretation (PIN) |
Review Conclusion |
A Permanent Interpretation is granted.
|
Problem Reporting System Options:
|