Status: Accepted
Owner:
[hidden email]
Labels: Milestone-1.4
New issue 4411 by
[hidden email]: examples in Number comments
http://code.google.com/p/pharo/issues/detail?id=4411Name: Kernel-cbc.593
Author: cbc
Time: 7 June 2011, 10:25:11.435 pm
UUID: 6ea87b7a-6755-1446-b2fd-54350609142c
Ancestors: Kernel-wiz.592
Added examples to the comments in Number #roundDownTo:, #roundUpTo:, and
#truncateTo: to clarify how to use the methods.
=============== Diff against Kernel-wiz.592 ===============
Item was changed:
----- Method: Number>>roundDownTo: (in category 'truncation and round
off') -----
roundDownTo: aNumber
"Answer the next multiple of aNumber toward negative infinity that
is nearest the
receiver."
+ "Examples:
+ 3.1479 roundDownTo: 0.01 -> 3.14
+ 3.1479 roundDownTo: 0.1 -> 3.1
+ 1923 roundDownTo: 10 -> 1920
+ 3.1479 roundDownTo: 0.005 -> 3.145
+ -3.1479 roundDownTo: 0.01 -> -3.15"
+
-
^(self/aNumber) floor * aNumber!
Item was changed:
----- Method: Number>>roundUpTo: (in category 'truncation and round off')
-----
roundUpTo: aNumber
"Answer the next multiple of aNumber toward infinity that is nearest
the
receiver."
+ "Examples:
+ 3.1479 roundUpTo: 0.01 -> 3.15
+ 3.1479 roundUpTo: 0.1 -> 3.2
+ 1923 roundUpTo: 10 -> 1930
+ 3.1479 roundUpTo: 0.005 -> 3.15
+ -3.1479 roundUpTo: 0.01 -> -3.14"
^(self/aNumber) ceiling * aNumber!
Item was changed:
----- Method: Number>>truncateTo: (in category 'truncation and round off')
-----
truncateTo: aNumber
"Answer the next multiple of aNumber toward zero that is nearest the
receiver."
+ "Examples:
+ 3.1479 truncateTo: 0.01 -> 3.14
+ 3.1479 truncateTo: 0.1 -> 3.1
+ 1923 truncateTo: 10 -> 1920
+ 3.1479 truncateTo: 0.005 -> 3.145
+ -3.1479 truncateTo: 0.01 -> -3.14"
^(self quo: aNumber)
* aNumber!
_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker