Mantis Bugtracker
  

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  fcsPrintShowingDecimals.cs.gz [^] (1,243 bytes) 12-15-06 06:33
 fcsNumberPrintShowingDecimals.3.cs.gz [^] (1,419 bytes) 02-14-07 21:55
 Number-printShowingDecimalPlace-Test-M5640-nice.1.cs [^] (1,379 bytes) 03-24-08 16:10
 Number-printShowingDecimalPlace-Patch-M5640-nice.1.cs [^] (2,667 bytes) 03-24-08 16:11
 Number-printShowingDecimalPlace-Patch-M5640-nice.2.cs [^] (2,667 bytes) 04-23-08 22:43
 Number-printShowingDecimalPlace-Test-M5640-nice.2.cs [^] (1,882 bytes) 04-23-08 23:01

- Relationships

SYSTEM WARNING: Creating default object from empty value

related to 0007134closed andreas Float rounded is inexact 
related to 0007028closed nicolas cellier printShowingDecimalPlaces: is broken in 3.10 
related to 0007372closed nicolas cellier printShowingDecimalPlaces: justify fraction to the #right instead of the #left 

- Notes
(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
 

- Issue History
Date Modified Username Field Change
12-15-06 06:33 franksergeant New Issue
12-15-06 06:33 franksergeant File Added: fcsPrintShowingDecimals.cs.gz
12-29-06 16:02 robdavid Issue Monitored: robdavid
02-14-07 21:55 franksergeant File Added: fcsNumberPrintShowingDecimals.3.cs.gz
02-14-07 22:00 franksergeant Note Added: 0009796
02-14-07 22:01 franksergeant Note Edited: 0009796
04-11-07 16:27 user291 Note Added: 0010524
11-24-07 00:43 nicolas cellier Note Added: 0011456
11-24-07 10:25 edgardec Note Added: 0011457
03-24-08 14:35 nicolas cellier Note Added: 0011951
03-24-08 14:47 nicolas cellier Note Edited: 0011951
03-24-08 16:10 nicolas cellier File Added: Number-printShowingDecimalPlace-Test-M5640-nice.1.cs
03-24-08 16:11 nicolas cellier File Added: Number-printShowingDecimalPlace-Patch-M5640-nice.1.cs
03-24-08 16:12 nicolas cellier Note Added: 0011952
03-24-08 16:13 nicolas cellier Note Edited: 0011951
04-23-08 22:43 nicolas cellier File Added: Number-printShowingDecimalPlace-Patch-M5640-nice.2.cs
04-23-08 22:46 nicolas cellier Note Added: 0012032
04-23-08 22:48 nicolas cellier Note Edited: 0012032
04-23-08 23:01 nicolas cellier File Added: Number-printShowingDecimalPlace-Test-M5640-nice.2.cs
04-23-08 23:01 nicolas cellier Note Edited: 0012032
04-23-08 23:02 nicolas cellier Note Edited: 0012032
04-25-08 00:04 Keith_Hodges Relationship added related to 0007028
05-09-08 18:35 Keith_Hodges Note Added: 0012063
07-26-08 01:28 wiz Relationship added related to 0007134
09-16-08 21:22 nicolas cellier Note Added: 0012672
01-07-09 16:48 KenCausey Note Added: 0012902
01-10-09 01:53 Keith_Hodges Status new => pending
01-10-09 03:34 Keith_Hodges Status pending => testing
01-10-09 03:39 Keith_Hodges Status testing => resolved
01-10-09 03:39 Keith_Hodges Fixed in Version  => 3.11
01-10-09 03:39 Keith_Hodges Resolution open => fixed
01-10-09 03:39 Keith_Hodges Assigned To  => Keith_Hodges
01-10-09 03:41 Keith_Hodges Status resolved => testing
02-16-09 00:31 KevinKelley Issue Monitored: KevinKelley
09-19-09 19:30 nicolas cellier Relationship added related to 0007372
09-19-09 20:22 nicolas cellier Note Added: 0013310
10-03-09 19:33 Keith_Hodges Status testing => assigned
10-03-09 19:33 Keith_Hodges Assigned To Keith_Hodges => andreas
10-03-09 20:20 nicolas cellier Status assigned => resolved
10-03-09 20:20 nicolas cellier Fixed in Version 3.11 => trunk
10-04-09 17:18 KenCausey Assigned To andreas => nicolas cellier
04-18-10 22:04 andreas Status resolved => closed


Mantis 1.0.8[^]
Copyright © 2000 - 2007 Mantis Group
144 total queries executed.
65 unique queries executed.
Powered by Mantis Bugtracker