[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Conversion decimal into fractional



On Dec 22, 2004, at 12:11 PM, Juan Sebastian Lach Lau wrote:

the postln is still there for debugging, very didactic but not useful for
working. Maybe you already took it.

yes I already removed it.


one more possible speedup:

	asFraction {|maxDenominator=100|
		var mediant, lower, upper;
		var n,d;
			// early exit if number is integer.
		if (this.trunc == this, { ^[this, 1] });
	...
	}

and maybe these would be useful too:

+ Symbol {
	asFraction { ^this }
}

+ SequenceableCollection {
	asFraction { ^this.collect { |el| el.asFraction } }
}

best, adc
--
--
Alberto de Campo
Bergstrasse 59/33
A-8020 Graz, Austria
e-mail : decampo@xxxxxx
--