/** * Converts a numeric value from this unit to the underlying derived unit. * * @param amount * The numeric value in this unit. * @return The equivalent value in the underlying derived unit. * @throws ConversionException * Can't convert value to the underlying derived unit. */ public double toDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) _unit).toDerivedUnit(amount * getScale()); }
/** * Converts a numeric value from this unit to the underlying derived unit. * * @param amount * The numeric value in this unit. * @return The equivalent value in the underlying derived unit. * @throws ConversionException * Can't convert value to the underlying derived unit. */ public double toDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) _unit).toDerivedUnit(amount * getScale()); }
/** * Converts a numeric value from the underlying derived unit to this unit. * * @param amount * The numeric value in the underlying derived unit. * @return The equivalent value in this unit. * @throws ConversionException * Can't convert value. */ public double fromDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } return ((DerivableUnit) getUnit()).fromDerivedUnit(amount) / getScale(); }
/** * Converts a numeric value from the underlying derived unit to this unit. * * @param amount * The numeric value in the underlying derived unit. * @return The equivalent value in this unit. * @throws ConversionException * Can't convert value. */ public double fromDerivedUnit(final double amount) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } return ((DerivableUnit) getUnit()).fromDerivedUnit(amount) / getScale(); }
/** * Converts numeric values from this unit to the underlying derived unit. * * @param input * The numeric values in this unit. * @param output * The equivalent values in the underlying derived unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values to the underlying derived unit. */ public float[] toDerivedUnit(final float[] input, final float[] output) throws ConversionException { final float scale = (float) getScale(); for (int i = input.length; --i >= 0;) { output[i] = input[i] * scale; } if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts numeric values from the underlying derived unit to this unit. * * @param input * The numeric values in the underlying derived unit. * @param output * The equivalent values in this unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values. */ public float[] fromDerivedUnit(final float[] input, final float[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final float scale = (float) getScale(); for (int i = input.length; --i >= 0;) { output[i] /= scale; } return output; }
/** * Converts numeric values from this unit to the underlying derived unit. * * @param input * The numeric values in this unit. * @param output * The equivalent values in the underlying derived unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values to the underlying derived unit. */ public double[] toDerivedUnit(final double[] input, final double[] output) throws ConversionException { final double scale = getScale(); for (int i = input.length; --i >= 0;) { output[i] = input[i] * scale; } if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts numeric values from this unit to the underlying derived unit. * * @param input * The numeric values in this unit. * @param output * The equivalent values in the underlying derived unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values to the underlying derived unit. */ public double[] toDerivedUnit(final double[] input, final double[] output) throws ConversionException { final double scale = getScale(); for (int i = input.length; --i >= 0;) { output[i] = input[i] * scale; } if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts numeric values from the underlying derived unit to this unit. * * @param input * The numeric values in the underlying derived unit. * @param output * The equivalent values in this unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values. */ public double[] fromDerivedUnit(final double[] input, final double[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final double scale = getScale(); for (int i = input.length; --i >= 0;) { output[i] /= scale; } return output; }
/** * Converts numeric values from this unit to the underlying derived unit. * * @param input * The numeric values in this unit. * @param output * The equivalent values in the underlying derived unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values to the underlying derived unit. */ public float[] toDerivedUnit(final float[] input, final float[] output) throws ConversionException { final float scale = (float) getScale(); for (int i = input.length; --i >= 0;) { output[i] = input[i] * scale; } if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(this, getDerivedUnit()); } return ((DerivableUnit) getUnit()).toDerivedUnit(output, output); }
/** * Converts numeric values from the underlying derived unit to this unit. * * @param input * The numeric values in the underlying derived unit. * @param output * The equivalent values in this unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values. */ public double[] fromDerivedUnit(final double[] input, final double[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final double scale = getScale(); for (int i = input.length; --i >= 0;) { output[i] /= scale; } return output; }
/** * Converts numeric values from the underlying derived unit to this unit. * * @param input * The numeric values in the underlying derived unit. * @param output * The equivalent values in this unit. * @return <code>output</code>. * @throws ConversionException * Can't convert values. */ public float[] fromDerivedUnit(final float[] input, final float[] output) throws ConversionException { if (!(_unit instanceof DerivableUnit)) { throw new ConversionException(getDerivedUnit(), this); } ((DerivableUnit) getUnit()).fromDerivedUnit(input, output); final float scale = (float) getScale(); for (int i = input.length; --i >= 0;) { output[i] /= scale; } return output; }