Anonymous | Login | 01-15-2021 17:21 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ View Advanced ] [ Issue History ] [ Print ] | ||||||||
ID | Category | Severity | Reproducibility | Date Submitted | Last Update | ||||
0005640 | [Squeak] Kernel | minor | always | 12-15-06 06:33 | 04-18-10 22:04 | ||||
Reporter | franksergeant | View Status | public | ||||||
Assigned To | nicolas cellier | ||||||||
Priority | normal | Resolution | fixed | ||||||
Status | closed | Product Version | 3.9 | ||||||
Summary | 0005640: additional tests and fixes for Number>>printShowingDecimalPlaces: | ||||||||
Description |
I noticed three problems with Number>>printShowingDecimalPlaces: 1. the leading minus sign was missing for negative numbers between 0 and -1, 2. rounding was screwy for both negative and positive numbers, 3. the category of the method is 'converting' but should be 'printing'. I have added several tests to NumberTest>>testPrintShowingDecimalPlaces to illustrate the problems. I included a test for the category in the tests and changed the category from 'converting' to 'printing' (but left it commented out? Feel free to email me to explain what I should have done if different -- frank@pygmy.utoh.org. /> Then, I modified Number>>printShowingDecimalPlaces: so the old and the new tests of NumberTest pass. |
||||||||
Additional Information |
In particular, -0.98 printShowingDecimalPlaces: 2 fails to show the minus sign, and 2.567 printShowingDecimalPlaces: 2 answers '2.56' but should answer '2.57'. The new version of #printShowingDecimalPlaces attached fixes those problems and still passes the other NumberTest tests. |
||||||||
Attached Files |
![]() ![]() ![]() ![]() ![]() ![]() |
||||||||
|
![]() |
||||||||||||||||
SYSTEM WARNING: Creating default object from empty value
|
![]() |
|
(0009796 - 519 - 597 - 597 - 597 - 597 - 597) franksergeant 02-14-07 22:00 edited on: 02-14-07 22:01 |
Scott Wallace pointed out that the version of #printShowingDecimalPlaces: in fcsPrintShowingDecimals.cs.gz (15 Dec 2006) fails in cases such as '0.01' printShowingDecimalPlaces: 2 I added an additional test for that and also a test for the case where the sign of the result should be different from the sign of the original number, e.g. '-0.001' printShowingDecimalPlaces: 2 Then I simplified the method considerably, and again all its tests pass. This newer version is fcsPrintShowingDecimals.3.cs.gz. |
(0010524 - 294 - 318 - 318 - 318 - 318 - 318) user291 04-11-07 16:27 |
I was having problems with: (953/100) printShowingDecimalPlaces: 2 in Squeak 3.9 7067. The 3.9 version prodces 9.52 but the correct result should be 9.53. The fcsNumberPrintShowingDecimals.3.cs.gz change set fixed this problem and hasn't caused me any problems in my development image. |
(0011456 - 204 - 372 - 372 - 372 - 372 - 372) nicolas cellier 11-24-07 00:43 |
I totally agree with second patch, though i would maybe write: ^sign , (integerString copyReplaceFrom: integerString size - placesDesired + 1 to: integerString size - placesDesired with: '.'). |
(0011457 - 83 - 89 - 89 - 89 - 89 - 89) edgardec 11-24-07 10:25 |
This now is 7157fcsPrintShowingDecimals.cs and was in 3.10 updates. Thanks Frank ! |
(0011951 - 921 - 1070 - 1070 - 1070 - 1070 - 1070) nicolas cellier 03-24-08 14:35 edited on: 03-24-08 16:13 |
Unfortunately i can exhibit some failure tests. First try this little overflow: (1.0d306 printShowingDecimalPlaces: 3). I can also build another case with an inexact rounding: 5000000000000001.0 printShowingDecimalPlaces: 0. "-> 5000000000000002" Above number is on 53 bits and thus represented exactly asFloat, it should therefore print exactly, but rounded algorithm is inexact.... Funnily, this number works with any other decimal places than 0. I can exploit the Float rounded inexact operation to construct a test case that fails with more decimal places: 50000000000001.25 printShowingDecimalPlaces: 2. "-> 50000000000001.26" 50000000000001.25 is also represented exactly (200000000000005.0 timesTwoPower: -2, with 200000000000005 highBit -> 48). The only way to do it exactly is to convert early to costly arithmetic: self asTrueFraction roundTo: (10 raisedTo: placesDesired) reciprocal. |
(0011952 - 211 - 265 - 265 - 265 - 265 - 265) nicolas cellier 03-24-08 16:12 |
"fix begin" Installer mantis bug: 5640 fix:'Number-printShowingDecimalPlace-Patch-M5640-nice.1.cs ' "fix test" Installer mantis bug: 5640 fix:'Number-printShowingDecimalPlace-Test-M5640-nice.1.cs'. "fix end" |
(0012032 - 361 - 451 - 451 - 641 - 641 - 641) nicolas cellier 04-23-08 22:46 edited on: 04-23-08 23:02 |
Arg, i blindly approved and copied the stupid padded right bug reported at 0007028 Here we go again... test.2.cs also includes a test for 0007028 "fix begin" Installer mantis bug: 5640 fix:'Number-printShowingDecimalPlace-Patch-M5640-nice.2.cs ' "fix test" Installer mantis bug: 5640 fix:'Number-printShowingDecimalPlace-Test-M5640-nice.2.cs'. "fix end" |
(0012063 - 211 - 265 - 265 - 265 - 265 - 265) Keith_Hodges 05-09-08 18:35 |
"fix begin" Installer mantis bug: 5640 fix:'Number-printShowingDecimalPlace-Patch-M5640-nice.2.cs'. "fix test" Installer mantis bug: 5640 fix:'Number-printShowingDecimalPlace-Test-M5640-nice.2.cs'. "fix end" |
(0012672 - 125 - 131 - 131 - 226 - 226 - 226) nicolas cellier 09-16-08 21:22 |
I suggest this issue be closed (if harvested in 7157 as announced). Any follow-up discussion should then take place at 0007028 |
(0012902 - 362 - 398 - 568 - 663 - 663 - 663) KenCausey 01-07-09 16:48 |
I would like to close this issue and move discussion to another, perhaps 0007028. But I would like to make sure we are all clear on the current status. Update 7157 http://ftp.squeak.org/updates/7157fcsPrintShowingDecimals.cs [^] harvests fcsPrintShowingDecimals.cs.gz of Dec 15th, 2006, not fcsNumberPrintShowingDecimals.3.cs.gz of Feb 14th, 2007. Thoughts? |
(0013310 - 119 - 131 - 131 - 131 - 131 - 131) nicolas cellier 09-19-09 20:22 |
Fixed in http:://source.squeak.org/trunk/KernelTests-nice.93.mcz http:://source.squeak.org/trunk/Kernel-nice.247.mcz |
Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
144 total queries executed. 65 unique queries executed. |