logo       

Re: Re: Proper fractions?: msg#00143

lang.smalltalk.squeak.beginners

Subject: Re: Re: Proper fractions?

On Thu, 26 Jul 2007 18:01:37 -0700, Blake <blake@xxxxxxxxxxxxxx> wrote:

Blake, if you actually want to make this work in your image, you could do this:

Fraction>>printOn: aStream base: base
| int |
(int := self integerPart) = 0
ifTrue: [aStream nextPut: $(.
numerator printOn: aStream base: base.
aStream nextPut: $/.
denominator printOn: aStream base: base.
aStream nextPut: $)]
ifFalse: [aStream nextPut: $(.
int printOn: aStream base: base.
aStream nextPut: $+.
self fractionPart printOn: aStream base: base.
aStream nextPut: $)]

(and delete Fraction>>printOn: which os redundant anyway)

I can see how this would be helpful in debugging if you deal with fractions a lot.

That's cool but I'm basically using the Fractions class for quick double-checks of math with fractions, so I sit down at whatever machine is handy, pull up Squeak and...

(Not that I'd object to printOn being changed or anything; it's just overkill.)

(Though I admit I put this in one of my images.)


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise