All pastes #11559 Raw Edit

Something

public text v1 · immutable
#11559 ·published 2005-05-12 02:06 UTC
rendered paste body
Integer>>printWithSeparators

	| n out start end index |
	out := WriteStream on: (String new: 10).

	n := self abs printString.
	end := n size.
	end < 4 ifTrue: [out nextPutAll: n. ^out contents].
	start := end \\ 3.
	index := 1.
	(n copyFrom: start + 1 to: end) reversed do: [:digit | 
		out nextPut: digit.
		(index \\ 3 = 0 and: [index < end]) ifTrue: [out nextPut: $,].
		index := index + 1].
	^(self < 0 ifTrue: ['-'] ifFalse: ['']), (n copyFrom: 1 to: start), out contents reversed