Return the inverse of value if not null or zero, using scale.
@param value the nullable BigDecimal
@param scale scale for the result if value is not null
@return 1 / value (if not null of zero)
508434
public static BigDecimal inverse(final BigDecimal value, final int scale) {
        return inverse(value, scale, BigDecimal.ROUND_HALF_UP);
    }
1296218
public static Float toNullableFloat(Object value) {
		Double result = DoubleConverter.toNullableDouble(value);
		return result != null ? (float) ((double) result) : null;
	}
197067
public static final BigDecimal printCurrency(Number value)
   {
      return (value == null || value.doubleValue() == 0 ? null : new BigDecimal(value.doubleValue() * 100));
   }
1186362
public void scale(double scale) {
		this.m00 *= scale;
		this.m11 *= scale;
		this.m01 *= scale;
		this.m10 *= scale;
	}
1007816
@Override
	public double transform(double value) {
		double sqrtValue = Double.NEGATIVE_INFINITY;
		if(value >= 0)
			sqrtValue = Math.sqrt(value);

		return sqrtValue;
	}
973498
public static BigRational valueOf(double value) {
		if (value == 0.0) {
			return ZERO;
		}
		if (value == 1.0) {
			return ONE;
		}
		if (Double.isInfinite(value)) {
			throw new NumberFormatException("Infinite");
		}
		if (Double.isNaN(value)) {
			throw new NumberFormatException("NaN");
		}
		return valueOf(new BigDecimal(String.valueOf(value)));
	}
107362
public static int getInheritedScale(AbstractCalculator calc, Num value) {
        if (value.getScale() == null) {
            if (calc != null && calc.getScale() != null)
                return calc.getScale();
            else
                return Properties.DEFAULT_SCALE;
        }
        else
            return value.getScale();
    }
36101
public Number getValue() {
		if ((getText() == null) || "".equals(getText().trim()))
			return null;
		try {
			Number n = format.parse(getText());
			if (n.getClass() == this.numberClass)
				return n;
			else if (this.numberClass == BigDecimal.class) {
				BigDecimal bd = new BigDecimal(n.doubleValue());
				if (scale != null) {
					bd = bd.setScale(scale.intValue(), BigDecimal.ROUND_HALF_UP);
				}
				return bd;
			}
			else if (this.numberClass == Double.class)
				return new Double(n.doubleValue());
			else if (this.numberClass == Float.class)
				return new Float(n.floatValue());
			else if (this.numberClass == BigInteger.class)
				// we have called setBigDecimalFormat to make sure a BigDecimal
				// is returned so use toBigInteger on that class
				return ((BigDecimal) n).toBigInteger();
			else if (this.numberClass == Long.class)
				return new Long(n.longValue());
			else if (this.numberClass == Integer.class)
				return new Integer(n.intValue());
			else if (this.numberClass == Short.class)
				return new Short(n.shortValue());
			else if (this.numberClass == Byte.class)
				return new Byte(n.byteValue());
			return null;
		}
		catch (Exception pe) {
			log.error("Error:  " + getText() + " is not a number.", pe);
			return null;
		}
	}
657710
public static float getFloat(
    Object      value)
  {
    if (value == null)
    {
        return 0;
    }

    return Float.valueOf(value.toString()).floatValue();
  }
95262
protected function setComponent(float $value, float $scale): float
    {
        return ($scale < 0) ? (1 - $value / -$scale) : ($value / $scale);
    }
615967
protected function getComponent(float $value, float $scale): float
    {
        return ($scale < 0) ? ((1 - $value) * -$scale) : ($value * $scale);
    }
571936
def scales(value):
        
        for i, entry in enumerate(value):
            _assert_is_type('scales[{0}]'.format(i), entry, Scale)
1086483
private int getColor(int value) {
		if (value == 0) {
			return 0;
		}

		double scale = Math.log10(value) / Math.log10(this.topValue);
		double lengthScale = Math.min(1.0, scale) * (colors.length - 1);
		int index = 1 + (int) lengthScale;
		if (index == colors.length) {
			index--;
		}
		double partScale = lengthScale - (index - 1);

		int r = (int) (colors[index - 1][0] + partScale
				* (colors[index][0] - colors[index - 1][0]));
		int g = (int) (colors[index - 1][1] + partScale
				* (colors[index][1] - colors[index - 1][1]));
		int b = (int) (colors[index - 1][2] + partScale
				* (colors[index][2] - colors[index - 1][2]));

		r = Math.min(255, r);
		b = Math.min(255, b);
		g = Math.min(255, g);
		return (r << 16) | (g << 8) | b;
	}
288356
private BigDecimal toBigDecimal(Object value) {
		if (value instanceof Long) {
			return new BigDecimal((Long) value);
		} else if (value instanceof Integer) {
			return new BigDecimal((Integer) value);
		} else if (value instanceof BigInteger) {
			return new BigDecimal((BigInteger) value);
		} else if(value instanceof Boolean) {
			return new BigDecimal((boolean)value ? 1 : 0);
		}

		//对于Double类型，先要转换为String，避免精度问题
		final String valueStr = convertToStr(value);
		if (StrUtil.isBlank(valueStr)) {
			return null;
		}
		return new BigDecimal(valueStr);
	}
818945
private static long getScaledValue(FileBuffer buffer, int scale,
                                       long position)
        throws IOException
    {
        return getScaledValue(new byte[8], buffer, scale, position);
    }
1294081
public static long getTimeScaleValue(int scale, int value)
    {
        TimeScaleData data = getTimeScaleData(scale);
        
        switch (value)
        {
        case UNITS_VALUE:
            return data.units;
            
        case EPOCH_OFFSET_VALUE:
            return data.epochOffset;
        
        case FROM_MIN_VALUE:
            return data.fromMin;
            
        case FROM_MAX_VALUE:
            return data.fromMax;
            
        case TO_MIN_VALUE:
            return data.toMin;
            
        case TO_MAX_VALUE:
            return data.toMax;
            
        case EPOCH_OFFSET_PLUS_1_VALUE:
            return data.epochOffsetP1;
            
        case EPOCH_OFFSET_MINUS_1_VALUE:
            return data.epochOffsetM1;
            
        case UNITS_ROUND_VALUE:
            return data.unitsRound;
        
        case MIN_ROUND_VALUE:
            return data.minRound;
            
        case MAX_ROUND_VALUE:
            return data.maxRound;
            
        default:
            throw new IllegalArgumentException("value out of range: " + value);
        }
    }
379675
public Double convertToDouble(String value) {
        Double result = null;
        if (value != null) {
            result = Double.valueOf(value);
        }
        return result;
    }