当前位置: 首页>>代码示例>>Java>>正文


Java BigDecimal.unscaledValue方法代码示例

本文整理汇总了Java中java.math.BigDecimal.unscaledValue方法的典型用法代码示例。如果您正苦于以下问题:Java BigDecimal.unscaledValue方法的具体用法?Java BigDecimal.unscaledValue怎么用?Java BigDecimal.unscaledValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.math.BigDecimal的用法示例。


在下文中一共展示了BigDecimal.unscaledValue方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serialize

import java.math.BigDecimal; //导入方法依赖的package包/类
public ByteBuffer serialize(BigDecimal value)
{
    if (value == null)
        return ByteBufferUtil.EMPTY_BYTE_BUFFER;

    BigInteger bi = value.unscaledValue();
    int scale = value.scale();
    byte[] bibytes = bi.toByteArray();

    ByteBuffer bytes = ByteBuffer.allocate(4 + bibytes.length);
    bytes.putInt(scale);
    bytes.put(bibytes);
    bytes.rewind();
    return bytes;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:16,代码来源:DecimalSerializer.java

示例2: encodeInternal

import java.math.BigDecimal; //导入方法依赖的package包/类
@Override
ByteBuffer encodeInternal(BigDecimal input) {
  BigInteger bi = input.unscaledValue();
  int scale = input.scale();
  byte[] bibytes = bi.toByteArray();

  ByteBuffer bytes = ByteBuffer.allocate(4 + bibytes.length);
  bytes.putInt(scale);
  bytes.put(bibytes);
  bytes.rewind();
  return bytes;
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:13,代码来源:CqlMapper.java

示例3: writeDecimal

import java.math.BigDecimal; //导入方法依赖的package包/类
protected void writeDecimal(BigDecimal o, Type type) {

        int        scale   = o.scale();
        BigInteger bigint  = o.unscaledValue();
        byte[]     bytearr = bigint.toByteArray();

        writeByteArray(bytearr);
        writeInt(scale);
    }
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:10,代码来源:RowOutputBinary.java

示例4: unscaledValue

import java.math.BigDecimal; //导入方法依赖的package包/类
public static BigInteger unscaledValue(BigDecimal o) {

//#ifdef JAVA2FULL
        return o.unscaledValue();

//#else
/*
        int scale = o.scale();
        return o.movePointRight(scale).toBigInteger();
*/

//#endif
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:14,代码来源:JavaSystem.java

示例5: writeBigDecimal

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * Writes {@link BigDecimal} value. The written value can be read via {@link #readBigDecimal(DataInput)}.
 *
 * @param val Value.
 * @param out Data output.
 *
 * @throws IOException if failed to write value.
 */
public static void writeBigDecimal(BigDecimal val, DataOutput out) throws IOException {
    if (val.compareTo(BigDecimal.ZERO) == 0) {
        out.writeByte(DECIMAL_ZERO);
    } else if (val.compareTo(BigDecimal.ONE) == 0) {
        out.writeByte(DECIMAL_ONE);
    } else if (val.compareTo(BigDecimal.TEN) == 0) {
        out.writeByte(DECIMAL_TEN);
    } else {
        int scale = val.scale();

        BigInteger unscaled = val.unscaledValue();

        int bits = unscaled.bitLength();

        if (bits <= 63) {
            if (scale == 0) {
                out.writeByte(DECIMAL_SMALL_UNSCALED);
                writeVarLong(unscaled.longValue(), out);
            } else {
                out.writeByte(DECIMAL_SMALL_SCALED);
                writeVarIntUnsigned(scale, out);
                writeVarLong(unscaled.longValue(), out);
            }
        } else {
            byte[] bytes = unscaled.toByteArray();

            out.writeByte(DECIMAL_BIG);
            writeVarIntUnsigned(scale, out);
            writeVarIntUnsigned(bytes.length, out);
            out.write(bytes, 0, bytes.length);
        }
    }
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:42,代码来源:CodecUtils.java

示例6: write

import java.math.BigDecimal; //导入方法依赖的package包/类
public static void write(BigDecimal d, DataOutput out) throws IOException {
  int scale = d.scale();
  BigInteger bigIntPart = d.unscaledValue();
  boolean fastpath = bigIntPart.compareTo(LONG_MAX_AS_BIGINT) < 0
      && bigIntPart .compareTo(LONG_MIN_AS_BIGINT) > 0;

  out.writeInt(scale);
  out.writeBoolean(fastpath);
  if (fastpath) {
    out.writeLong(bigIntPart.longValue());
  } else {
    Text.writeString(out, bigIntPart.toString());
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:15,代码来源:BigDecimalSerializer.java

示例7: toBigInteger

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * <p>BigInteger value of BigDecimal value.</p>
 *
 * @param value Value to convert.
 * @param canBeNull Can returned value be null?
 *
 * @return BigInteger value of BigDecimal, possibly null.
 */
private static BigInteger toBigInteger(
    BigDecimal value,
    boolean canBeNull) {
    if (canBeNull && value.signum() == 0) {
        return null;
    } else {
        return value.unscaledValue();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:DurationImpl.java

示例8: getUnscaledValue

import java.math.BigDecimal; //导入方法依赖的package包/类
public static BigInteger getUnscaledValue(BigDecimal o) {

//#ifdef JAVA1TARGET
/*
        int scale = o.scale();
        return o.movePointRight(scale).toBigInteger();
*/

//#else
        return o.unscaledValue();

//#endif
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:14,代码来源:JavaSystem.java

示例9: getUnscaledValue

import java.math.BigDecimal; //导入方法依赖的package包/类
public static BigInteger getUnscaledValue(BigDecimal o) {

//#ifdef JAVA2FULL
        return o.unscaledValue();

//#else
/*
        int scale = o.scale();
        return o.movePointRight(scale).toBigInteger();
*/

//#endif
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:14,代码来源:JavaSystem.java

示例10: toBigInteger

import java.math.BigDecimal; //导入方法依赖的package包/类
/**
 * <p>BigInteger value of BigDecimal value.</p>
 *
 * @param value Value to convert.
 * @param canBeNull Can returned value be null?
 *
 * @return BigInteger value of BigDecimal, possibly null.
 */
private static BigInteger toBigInteger(
    BigDecimal value,
    boolean canBeNull) {
    if (canBeNull && value.signum() == 0) {
        return null;
    }
    else {
        return value.unscaledValue();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:DurationImpl.java


注:本文中的java.math.BigDecimal.unscaledValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。