Here you can find the source of floatToSemiPrecision(float f, byte abyte0[], int i)
public static final void floatToSemiPrecision(float f, byte abyte0[], int i)
//package com.java2s; /**//from ww w. ja v a 2 s.co m * This file is part of JEMMA - http://jemma.energy-home.org * (C) Copyright 2013 Telecom Italia (http://www.telecomitalia.it) * * JEMMA is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License (LGPL) version 3 * or later as published by the Free Software Foundation, which accompanies * this distribution and is available at http://www.gnu.org/licenses/lgpl.html * * JEMMA is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License (LGPL) for more details. * */ public class Main { public static final void floatToSemiPrecision(float f, byte abyte0[], int i) { int j = Float.floatToIntBits(f); int k = j >> 23; k &= 0xff; int l = j << 9; l >>>= 9; int i1 = l >> 13; int j1 = (j >>> 31) << 15; int k1; if (k == 255) { k1 = 31744; k1 |= j1; } else if (k == 0) { k1 = j1 | i1; } else { int l1 = k - 112; l1 <<= 10; k1 = j1 | l1 | i1; } _16BitsToLittleEndian(k1, abyte0, i); } public static final void _16BitsToLittleEndian(int i, byte abyte0[], int j) { abyte0[j] = (byte) (0xff & i >>> 0); abyte0[j + 1] = (byte) (0xff & i >>> 8); } }