java.lang.Math.getExponent()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(302)

本文整理了Java中java.lang.Math.getExponent()方法的一些代码示例,展示了Math.getExponent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Math.getExponent()方法的具体详情如下:
包路径:java.lang.Math
类名称:Math
方法名:getExponent

Math.getExponent介绍

[英]Returns the unbiased base-2 exponent of double d.
[中]返回双d的无偏基2指数。

代码示例

代码示例来源:origin: google/guava

  1. static boolean isNormal(double d) {
  2. return getExponent(d) >= MIN_EXPONENT;
  3. }

代码示例来源:origin: google/guava

  1. static boolean isFinite(double d) {
  2. return getExponent(d) <= MAX_EXPONENT;
  3. }

代码示例来源:origin: prestodb/presto

  1. static boolean isFinite(double d) {
  2. return getExponent(d) <= MAX_EXPONENT;
  3. }

代码示例来源:origin: prestodb/presto

  1. static boolean isNormal(double d) {
  2. return getExponent(d) >= MIN_EXPONENT;
  3. }

代码示例来源:origin: google/j2objc

  1. static boolean isFinite(double d) {
  2. return getExponent(d) <= MAX_EXPONENT;
  3. }

代码示例来源:origin: google/j2objc

  1. static boolean isNormal(double d) {
  2. return getExponent(d) >= MIN_EXPONENT;
  3. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the exponent of float {@code f}.
  3. * @since 1.6
  4. */
  5. public static int getExponent(float f) {
  6. return Math.getExponent(f);
  7. }

代码示例来源:origin: robovm/robovm

  1. /**
  2. * Returns the exponent of double {@code d}.
  3. * @since 1.6
  4. */
  5. public static int getExponent(double d){
  6. return Math.getExponent(d);
  7. }

代码示例来源:origin: google/guava

  1. static long getSignificand(double d) {
  2. checkArgument(isFinite(d), "not a normal value");
  3. int exponent = getExponent(d);
  4. long bits = doubleToRawLongBits(d);
  5. bits &= SIGNIFICAND_MASK;
  6. return (exponent == MIN_EXPONENT - 1) ? bits << 1 : bits | IMPLICIT_BIT;
  7. }

代码示例来源:origin: apache/incubator-druid

  1. @Override
  2. protected ExprEval eval(double param)
  3. {
  4. return ExprEval.of(Math.getExponent(param));
  5. }
  6. }

代码示例来源:origin: google/j2objc

  1. static long getSignificand(double d) {
  2. checkArgument(isFinite(d), "not a normal value");
  3. int exponent = getExponent(d);
  4. long bits = doubleToRawLongBits(d);
  5. bits &= SIGNIFICAND_MASK;
  6. return (exponent == MIN_EXPONENT - 1) ? bits << 1 : bits | IMPLICIT_BIT;
  7. }

代码示例来源:origin: google/guava

  1. /**
  2. * Returns {@code true} if {@code x} represents a mathematical integer.
  3. *
  4. * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
  5. * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
  6. */
  7. @GwtIncompatible // java.lang.Math.getExponent, com.google.common.math.DoubleUtils
  8. public static boolean isMathematicalInteger(double x) {
  9. return isFinite(x)
  10. && (x == 0.0
  11. || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
  12. }

代码示例来源:origin: wildfly/wildfly

  1. static long getSignificand(double d) {
  2. checkArgument(isFinite(d), "not a normal value");
  3. int exponent = getExponent(d);
  4. long bits = doubleToRawLongBits(d);
  5. bits &= SIGNIFICAND_MASK;
  6. return (exponent == MIN_EXPONENT - 1) ? bits << 1 : bits | IMPLICIT_BIT;
  7. }

代码示例来源:origin: prestodb/presto

  1. static long getSignificand(double d) {
  2. checkArgument(isFinite(d), "not a normal value");
  3. int exponent = getExponent(d);
  4. long bits = doubleToRawLongBits(d);
  5. bits &= SIGNIFICAND_MASK;
  6. return (exponent == MIN_EXPONENT - 1) ? bits << 1 : bits | IMPLICIT_BIT;
  7. }

代码示例来源:origin: google/guava

  1. /**
  2. * Returns the {@code BigInteger} value that is equal to {@code x} rounded with the specified
  3. * rounding mode, if possible.
  4. *
  5. * @throws ArithmeticException if
  6. * <ul>
  7. * <li>{@code x} is infinite or NaN
  8. * <li>{@code x} is not a mathematical integer and {@code mode} is {@link
  9. * RoundingMode#UNNECESSARY}
  10. * </ul>
  11. */
  12. // #roundIntermediate, java.lang.Math.getExponent, com.google.common.math.DoubleUtils
  13. @GwtIncompatible
  14. public static BigInteger roundToBigInteger(double x, RoundingMode mode) {
  15. x = roundIntermediate(x, mode);
  16. if (MIN_LONG_AS_DOUBLE - x < 1.0 & x < MAX_LONG_AS_DOUBLE_PLUS_ONE) {
  17. return BigInteger.valueOf((long) x);
  18. }
  19. int exponent = getExponent(x);
  20. long significand = getSignificand(x);
  21. BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
  22. return (x < 0) ? result.negate() : result;
  23. }

代码示例来源:origin: prestodb/presto

  1. /**
  2. * Returns {@code true} if {@code x} represents a mathematical integer.
  3. *
  4. * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
  5. * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
  6. */
  7. @GwtIncompatible // java.lang.Math.getExponent, com.facebook.presto.jdbc.internal.guava.math.DoubleUtils
  8. public static boolean isMathematicalInteger(double x) {
  9. return isFinite(x)
  10. && (x == 0.0
  11. || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
  12. }

代码示例来源:origin: prestodb/presto

  1. /**
  2. * Returns the {@code BigInteger} value that is equal to {@code x} rounded with the specified
  3. * rounding mode, if possible.
  4. *
  5. * @throws ArithmeticException if
  6. * <ul>
  7. * <li>{@code x} is infinite or NaN
  8. * <li>{@code x} is not a mathematical integer and {@code mode} is {@link
  9. * RoundingMode#UNNECESSARY}
  10. * </ul>
  11. */
  12. // #roundIntermediate, java.lang.Math.getExponent, com.facebook.presto.jdbc.internal.guava.math.DoubleUtils
  13. @GwtIncompatible
  14. public static BigInteger roundToBigInteger(double x, RoundingMode mode) {
  15. x = roundIntermediate(x, mode);
  16. if (MIN_LONG_AS_DOUBLE - x < 1.0 & x < MAX_LONG_AS_DOUBLE_PLUS_ONE) {
  17. return BigInteger.valueOf((long) x);
  18. }
  19. int exponent = getExponent(x);
  20. long significand = getSignificand(x);
  21. BigInteger result = BigInteger.valueOf(significand).shiftLeft(exponent - SIGNIFICAND_BITS);
  22. return (x < 0) ? result.negate() : result;
  23. }

代码示例来源:origin: google/j2objc

  1. /**
  2. * Returns {@code true} if {@code x} represents a mathematical integer.
  3. *
  4. * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
  5. * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
  6. */
  7. @GwtIncompatible // java.lang.Math.getExponent, com.google.common.math.DoubleUtils
  8. public static boolean isMathematicalInteger(double x) {
  9. return isFinite(x)
  10. && (x == 0.0
  11. || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
  12. }

代码示例来源:origin: wildfly/wildfly

  1. /**
  2. * Returns {@code true} if {@code x} represents a mathematical integer.
  3. *
  4. * <p>This is equivalent to, but not necessarily implemented as, the expression {@code
  5. * !Double.isNaN(x) && !Double.isInfinite(x) && x == Math.rint(x)}.
  6. */
  7. @GwtIncompatible // java.lang.Math.getExponent, com.google.common.math.DoubleUtils
  8. public static boolean isMathematicalInteger(double x) {
  9. return isFinite(x)
  10. && (x == 0.0
  11. || SIGNIFICAND_BITS - Long.numberOfTrailingZeros(getSignificand(x)) <= getExponent(x));
  12. }

代码示例来源:origin: google/guava

  1. public static int log2(double x, RoundingMode mode) {
  2. checkArgument(x > 0.0 && isFinite(x), "x must be positive and finite");
  3. int exponent = getExponent(x);
  4. if (!isNormal(x)) {
  5. return log2(x * IMPLICIT_BIT, mode) - SIGNIFICAND_BITS;

相关文章