Java BigInteger Calculate splitFloat(BigInteger rawFloat, int signWidth, int exponentWidth, int mantissaWidth)

Here you can find the source of splitFloat(BigInteger rawFloat, int signWidth, int exponentWidth, int mantissaWidth)

Description

split Float

License

Mozilla Public License

Declaration

public static BigInteger[] splitFloat(BigInteger rawFloat,
            int signWidth, int exponentWidth, int mantissaWidth) 

Method Source Code

//package com.java2s;
/*//from  w  w w . j  a v a 2 s  .  c o m
 * Copyright © 2010-2011 Rebecca G. Bettencourt / Kreative Software
 * <p>
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * <a href="http://www.mozilla.org/MPL/">http://www.mozilla.org/MPL/</a>
 * <p>
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 * <p>
 * Alternatively, the contents of this file may be used under the terms
 * of the GNU Lesser General Public License (the "LGPL License"), in which
 * case the provisions of LGPL License are applicable instead of those
 * above. If you wish to allow use of your version of this file only
 * under the terms of the LGPL License and not to allow others to use
 * your version of this file under the MPL, indicate your decision by
 * deleting the provisions above and replace them with the notice and
 * other provisions required by the LGPL License. If you do not delete
 * the provisions above, a recipient may use your version of this file
 * under either the MPL or the LGPL License.
 * @since KSFL 1.2
 * @author Rebecca G. Bettencourt, Kreative Software
 */

import java.math.BigInteger;

public class Main {
    public static BigInteger[] splitFloat(BigInteger rawFloat,
            int signWidth, int exponentWidth, int mantissaWidth) {
        BigInteger rawSign = rawFloat.shiftRight(
                exponentWidth + mantissaWidth).and(
                BigInteger.ONE.shiftLeft(signWidth)
                        .subtract(BigInteger.ONE));
        BigInteger rawExponent = rawFloat.shiftRight(mantissaWidth).and(
                BigInteger.ONE.shiftLeft(exponentWidth).subtract(
                        BigInteger.ONE));
        BigInteger rawMantissa = rawFloat.and(BigInteger.ONE.shiftLeft(
                mantissaWidth).subtract(BigInteger.ONE));
        return new BigInteger[] { rawSign, rawExponent, rawMantissa };
    }
}

Related

  1. serializeQuery(BigInteger modulus, BigInteger base, BigInteger exponent, boolean brief, String... modexps)
  2. shift(BigInteger integer, int distance)
  3. shiftLeft(final BigInteger register, final BigInteger input, final int n)
  4. split(BigInteger maxValue, int numberOfSplits)
  5. splitBigInt(BigInteger value, int n)
  6. sqrt(BigInteger n)
  7. sqrt(BigInteger n)
  8. sqrt(BigInteger n)
  9. square(BigInteger x)