On Sep 16, 7:51 am, Rich Hickey <[EMAIL PROTECTED]> wrote:
...
> The workaround I came up with fails to filter the bridge method in
> org.jscience.physics.amount.Amount. I'm still looking into this issue.
>
> http://groups.google.com/group/jvm-languages/browse_frm/thread/a64c75...
>
> Rich
Below is the source code from Amount.divide and Amount.times for the
long and double parameter versions. Other than the obvious
substitution of variable and operator names, the times <double> and
divide <double> methods are structurally equivalent. The times <long>
and divide <long> method have one difference: the divide method makes
use of local variables <min> and <max> -- as do both double methods --
the times <long> method directly assigns the result of calculation
into the m._minimum and m._maximum fields.
===========Java code excerpt from Amount.java====================
public Amount<Q> times(double factor) {
Amount<Q> m = Amount.newInstance(_unit);
double min = (factor > 0) ? _minimum * factor : _maximum *
factor;
double max = (factor > 0) ? _maximum * factor : _minimum *
factor;
m._isExact = false;
m._minimum = (min < 0) ? min * INCREMENT : min * DECREMENT;
m._maximum = (max < 0) ? max * DECREMENT : max * INCREMENT;
return m;
}
public Amount<Q> divide(double divisor) {
Amount<Q> m = Amount.newInstance(_unit);
double min = (divisor > 0) ? _minimum / divisor : _maximum /
divisor;
double max = (divisor > 0) ? _maximum / divisor : _minimum /
divisor;
m._isExact = false;
m._minimum = (min < 0) ? min * INCREMENT : min * DECREMENT;
m._maximum = (max < 0) ? max * DECREMENT : max * INCREMENT;
return m;
}
public Amount<Q> times(long factor) {
Amount<Q> m = Amount.newInstance(_unit);
if (this._isExact) {
long productLong = _exactValue * factor;
double productDouble = ((double) _exactValue) * factor;
if (productLong == productDouble)
return m.setExact(productLong);
}
m._isExact = false;
m._minimum = (factor > 0) ? _minimum * factor : _maximum *
factor;
m._maximum = (factor > 0) ? _maximum * factor : _minimum *
factor;
return m;
}
public Amount<Q> divide(long divisor) {
Amount<Q> m = Amount.newInstance(_unit);
if (this._isExact) {
long quotientLong = _exactValue / divisor;
double quotientDouble = ((double) _exactValue) / divisor;
if (quotientLong == quotientDouble)
return m.setExact(quotientLong);
}
double min = (divisor > 0) ? _minimum / divisor : _maximum /
divisor;
double max = (divisor > 0) ? _maximum / divisor : _minimum /
divisor;
m._isExact = false;
m._minimum = (min < 0) ? min * INCREMENT : min * DECREMENT;
m._maximum = (max < 0) ? max * DECREMENT : max * INCREMENT;
return m;
}
=================================================
Could this difference be triggering the jdk/vm 1.6 into treating the
<whatever the name for the aggregate of> the 'times' methods
differently from the <whatever the name for the aggregate of> the
'divide' method?
Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---