Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Sep 28, 2019
1 parent ae56653 commit 340826a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/Collections-Strings/String.class.st
Expand Up @@ -2519,10 +2519,8 @@ String >> truncateTo: smallSize [
"return myself or a copy shortened to smallSize."
^ self size <= smallSize
ifTrue:
[self]
ifFalse:
[self copyFrom: 1 to: smallSize]
ifTrue: [ self ]
ifFalse: [ self copyFrom: 1 to: smallSize ]
]
{ #category : #converting }
Expand Down
17 changes: 9 additions & 8 deletions src/Kernel/Number.class.st
Expand Up @@ -777,14 +777,15 @@ Number >> stringForReadout [

{ #category : #'truncation and round off' }
Number >> 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"

"Answer the next multiple of aNumber toward zero that is nearest the receiver."
"(3.1479 truncateTo: 0.01) >>> 3.14"
"(3.1479 truncateTo: 0.1) >>> 3.1"
"(1923 truncateTo: 10) >>> 1920"
"(1929 truncateTo: 10) >>> 1920"
"(-1929 truncateTo: 10) >>> -1920"
"(3.1479 truncateTo: 0.005) >>> 3.145"
"(-3.1479 truncateTo: 0.01) >>> -3.14"

^(self quo: aNumber) * aNumber
]

Expand Down

0 comments on commit 340826a

Please sign in to comment.