Commit e78172d1 authored by Cerlane Leong's avatar Cerlane Leong 💬

P8 support, renaming helper functions, support for cast type and housekeeping

parent d2214bf3
V0.3:
Full posit16_t (es=1) and posit8_t (es=0) support.
es: exponential size
Changes:
1) convertQ16ToP16 will be deprecated. New function name: q16_to_p16
2) New cast type support.
To cast posit binary expressed in unsigned integer into positx_t type:
posit16_t castP16(uint16_t)
posit8_t castP8(uint8_t)
To cast positx_t to posit binary expressed in unsigned integer
uint16_t castUI16(posit16_t)
uint8_t castUI8(posit8_t)
3) Helper functions renamed:
convertP16ToDec_f to convertP16ToDouble
convertdoubleToP16 to convertDoubleToP16
4) Full P8 support
V0.2:
Full posit16_t (16-bit posit with 1 exponent bit) support
......@@ -8,4 +27,4 @@ Added four functions:
4) convert long int to posit16_t
Bug fix:
1) Fixed p16_mulAdd bug (https://gitlab.com/cerlane/SoftPosit/issues/1)
\ No newline at end of file
1) Fixed p16_mulAdd bug (https://gitlab.com/cerlane/SoftPosit/issues/1)
......@@ -43,9 +43,10 @@ SOURCE_DIR ?= ../../source
SPECIALIZE_TYPE ?= 8086-SSE
SOFTPOSIT_OPTS ?= \
-DINLINE_LEVEL=5
-DINLINE_LEVEL=5 #\
-DSOFTPOSIT_QUAD -lquadmath
#-lquadmath
DELETE = rm -f
C_INCLUDES = -I. -I$(SOURCE_DIR)/$(SPECIALIZE_TYPE) -I$(SOURCE_DIR)/include
OPTIMISATION = -march=core-avx2 -O2
......@@ -61,11 +62,39 @@ LIB = .a
.PHONY: all
all: softposit$(LIB)
quad: SOFTPOSIT_OPTS+= -DSOFTPOSIT_QUAD -lquadmath
quad: all
OBJS_PRIMITIVES =
OBJS_SPECIALIZE =
OBJS_OTHERS = \
s_addMagsP8$(OBJ) \
s_subMagsP8$(OBJ) \
s_mulAddP8$(OBJ) \
p8_add$(OBJ) \
p8_sub$(OBJ) \
p8_mul$(OBJ) \
p8_div$(OBJ) \
p8_sqrt$(OBJ) \
p8_to_p16$(OBJ) \
p8_to_p32$(OBJ) \
p8_to_i32$(OBJ) \
p8_to_i64$(OBJ) \
p8_to_ui32$(OBJ) \
p8_to_ui64$(OBJ) \
p8_roundToInt$(OBJ) \
p8_mulAdd$(OBJ) \
p8_eq$(OBJ) \
p8_le$(OBJ) \
p8_lt$(OBJ) \
quire8_fdp_add$(OBJ) \
quire8_fdp_sub$(OBJ) \
ui32_to_p8$(OBJ) \
ui64_to_p8$(OBJ) \
i32_to_p8$(OBJ) \
i64_to_p8$(OBJ) \
s_addMagsP16$(OBJ) \
s_subMagsP16$(OBJ) \
s_mulAddP16$(OBJ) \
......@@ -73,6 +102,7 @@ OBJS_OTHERS = \
p16_to_ui64$(OBJ) \
p16_to_i32$(OBJ) \
p16_to_i64$(OBJ) \
p16_to_p8$(OBJ) \
p16_to_p32$(OBJ) \
p16_roundToInt$(OBJ) \
p16_add$(OBJ) \
......@@ -84,17 +114,22 @@ OBJS_OTHERS = \
p16_le$(OBJ) \
p16_lt$(OBJ) \
p16_sqrt$(OBJ) \
quire16_fdp_add$(OBJ) \
quire16_fdp_sub$(OBJ) \
quire_helper$(OBJ) \
ui32_to_p16$(OBJ) \
ui64_to_p16$(OBJ) \
i32_to_p16$(OBJ) \
i64_to_p16$(OBJ) \
quire16_fdp_add$(OBJ) \
quire16_fdp_sub$(OBJ) \
quire_helper$(OBJ) \
s_approxRecipSqrt_1Ks$(OBJ) \
c_convertDecToPosit8$(OBJ) \
c_convertPosit8ToDec$(OBJ) \
c_convertDecToPosit16$(OBJ) \
c_convertPosit16ToDec$(OBJ) \
c_convertQuire16ToPosit16$(OBJ)
c_convertQuire8ToPosit8$(OBJ) \
c_convertQuire16ToPosit16$(OBJ) \
c_convertDecToPosit32$(OBJ) \
c_convertPosit32ToDec$(OBJ)
OBJS_ALL = $(OBJS_PRIMITIVES) $(OBJS_SPECIALIZE) $(OBJS_OTHERS)
......
/*============================================================================
This C header file is part of the SoftPosit Posit Arithmetic Package
by S. H. Leong (Cerlane).
Copyright 2017 2018 A*STAR. All rights reserved.
This C header file was based on SoftFloat IEEE Floating-Point Arithmetic
Package, Release 3d, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions, and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#define LITTLEENDIAN 1
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#ifdef __GNUC_STDC_INLINE__
#define INLINE inline
#else
#define INLINE extern inline
#endif
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
Package, Release 3d, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions, and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#define LITTLEENDIAN 1
/*----------------------------------------------------------------------------
*----------------------------------------------------------------------------*/
#ifdef __GNUC_STDC_INLINE__
#define INLINE inline
#else
#define INLINE extern inline
#endif
/*============================================================================
This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
This C header file is part of the SoftPosit Posit Arithmetic Package
by S. H. Leong (Cerlane).
Copyright 2017 2018 A*STAR. All rights reserved.
This C header file was based on SoftFloat IEEE Floating-Point Arithmetic
Package, Release 3d, by John R. Hauser.
Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
......@@ -40,6 +45,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <stdbool.h>
#include <stdint.h>
#include "../include/softposit_types.h"
#include "softposit_types.h"
#endif
......@@ -32,14 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include <stdbool.h>
#include <stdint.h>
#include <math.h>
#include "softposit.h"
#include "platform.h"
#include "internals.h"
#include "specialize.h"
void checkExtraTwoBitsP16(double f16, double temp, bool * bitsNPlusOne, bool * bitsMore ){
temp /= 2;
......@@ -93,12 +89,12 @@ uint_fast16_t convertFractionP16(double f16, uint_fast8_t fracLength, bool * bit
return frac;
}
posit16_t convertfloatToP16(float a){
posit16_t convertFloatToP16(float a){
posit16 b = {.f = (double) a };
return convertDecToP16(b);
}
posit16_t convertdoubleToP16(double a){
posit16_t convertDoubleToP16(double a){
posit16 b = {.f = a };
return convertDecToP16(b);
}
......@@ -253,203 +249,206 @@ posit16_t convertDecToP16(posit16 a){
}
/*void checkQuadExtraTwoBitsP16(__float128 f16, double temp, bool * bitsNPlusOne, bool * bitsMore ){
temp /= 2;
if (temp<=f16){
*bitsNPlusOne = 1;
f16-=temp;
#ifdef SOFTPOSIT_QUAD
void checkQuadExtraTwoBitsP16(__float128 f16, double temp, bool * bitsNPlusOne, bool * bitsMore ){
temp /= 2;
if (temp<=f16){
*bitsNPlusOne = 1;
f16-=temp;
}
if (f16>0)
*bitsMore = 1;
}
if (f16>0)
*bitsMore = 1;
}
uint_fast16_t convertQuadFractionP16(__float128 f16, uint_fast8_t fracLength, bool * bitsNPlusOne, bool * bitsMore ){
uint_fast16_t convertQuadFractionP16(__float128 f16, uint_fast8_t fracLength, bool * bitsNPlusOne, bool * bitsMore ){
uint_fast16_t frac=0;
uint_fast16_t frac=0;
if(f16==0) return 0;
else if(f16==INFINITY) return INFINITY;
if(f16==0) return 0;
else if(f16==INFINITY) return INFINITY;
f16 -= 1; //remove hidden bit
if (fracLength==0)
checkQuadExtraTwoBitsP16(f16, 1.0, bitsNPlusOne, bitsMore);
else{
__float128 temp = 1;
while (true){
temp /= 2;
if (temp<=f16){
f16-=temp;
fracLength--;
frac = (frac<<1) + 1; //shift in one
if (f16==0){
//put in the rest of the bits
frac <<= (uint_fast8_t)fracLength;
break;
f16 -= 1; //remove hidden bit
if (fracLength==0)
checkQuadExtraTwoBitsP16(f16, 1.0, bitsNPlusOne, bitsMore);
else{
__float128 temp = 1;
while (true){
temp /= 2;
if (temp<=f16){
f16-=temp;
fracLength--;
frac = (frac<<1) + 1; //shift in one
if (f16==0){
//put in the rest of the bits
frac <<= (uint_fast8_t)fracLength;
break;
}
if (fracLength == 0){
checkQuadExtraTwoBitsP16(f16, temp, bitsNPlusOne, bitsMore);
break;
}
}
if (fracLength == 0){
checkQuadExtraTwoBitsP16(f16, temp, bitsNPlusOne, bitsMore);
break;
}
}
else{
frac <<= 1; //shift in a zero
fracLength--;
if (fracLength == 0){
checkQuadExtraTwoBitsP16(f16, temp, bitsNPlusOne, bitsMore);
break;
else{
frac <<= 1; //shift in a zero
fracLength--;
if (fracLength == 0){
checkQuadExtraTwoBitsP16(f16, temp, bitsNPlusOne, bitsMore);
break;
}
}
}
}
return frac;
}
//printf("convertfloat: frac:%d f16: %.26f bitsNPlusOne: %d, bitsMore: %d\n", frac, f16, bitsNPlusOne, bitsMore);
posit16_t convertQuadToP16(__float128 f16){
union ui16_p16 uZ;
bool sign, regS;
uint_fast16_t reg, frac=0;
int_fast8_t exp=0;
bool bitNPlusOne=0, bitsMore=0;
return frac;
}
(f16>=0) ? (sign=0) : (sign=1);
if (f16 == 0 ){
uZ.ui = 0;
return uZ.p;
}
else if(f16 == INFINITY || f16 == -INFINITY){
uZ.ui = 0x8000;
return uZ.p;
}
else if (f16 == 1) {
uZ.ui = 16384;
return uZ.p;
}
else if (f16 == -1){
uZ.ui = 49152;
return uZ.p;
}
else if (f16 >= 268435456){
//maxpos
uZ.ui = 32767;
return uZ.p;
}
else if (f16 <= -268435456){
// -maxpos
uZ.ui = 32769;
return uZ.p;
}
else if(f16 <= 3.725290298461914e-9 && !sign){
//minpos
uZ.ui = 1;
return uZ.p;
}
else if(f16 >= -3.725290298461914e-9 && sign){
//-minpos
uZ.ui = 65535;
return uZ.p;
}
else if (f16>1 || f16<-1){
if (sign){
//Make negative numbers positive for easier computation
f16 = -f16;
}
regS = 1;
reg = 1; //because k = m-1; so need to add back 1
// minpos
if (f16 <= 3.725290298461914e-9){
uZ.ui = 1;
}
else{
//regime
while (f16>=4){
f16 *=0.25;
reg++;
}
if (f16>=2){
f16*=0.5;
exp++;
}
posit16_t convertQuadToP16(__float128 f16){
union ui16_p16 uZ;
bool sign, regS;//, bitsNPlusOne=0, bitsMore=0;
uint_fast16_t reg, frac=0;
int_fast8_t exp=0;
bool bitNPlusOne=0, bitsMore=0;
int8_t fracLength = 13-reg;
if (fracLength<0){
//reg == 14, means rounding bits is exp and just the rest.
if (f16>1) bitsMore = 1;
}
else
frac = convertQuadFractionP16 (f16, fracLength, &bitNPlusOne, &bitsMore);
(f16>=0) ? (sign=0) : (sign=1);
// sign: 1 bit, frac: 8 bits, mantisa: 23 bits
//sign = a.parts.sign;
//frac = a.parts.fraction;
//exp = a.parts.exponent;
if (reg==14 && frac>0) {
bitsMore = 1;
frac=0;
}
if (f16 == 0 ){
uZ.ui = 0;
return uZ.p;
}
else if(f16 == INFINITY || f16 == -INFINITY){
uZ.ui = 0x8000;
return uZ.p;
}
else if (f16 == 1) {
uZ.ui = 16384;
return uZ.p;
}
else if (f16 == -1){
uZ.ui = 49152;
return uZ.p;
}
else if (f16 >= 268435456){
//maxpos
uZ.ui = 32767;
return uZ.p;
}
else if (f16 <= -268435456){
// -maxpos
uZ.ui = 32769;
return uZ.p;
}
else if(f16 <= 3.725290298461914e-9 && !sign){
//minpos
uZ.ui = 1;
return uZ.p;
}
else if(f16 >= -3.725290298461914e-9 && sign){
//-minpos
uZ.ui = 65535;
return uZ.p;
}
else if (f16>1 || f16<-1){
if (sign){
//Make negative numbers positive for easier computation
f16 = -f16;
}
//printf("float to p16: %.16f \n",f16);
regS = 1;
reg = 1; //because k = m-1; so need to add back 1
// minpos
if (f16 <= 3.725290298461914e-9){
uZ.ui = 1;
if (reg>14)
(regS) ? (uZ.ui= 32767): (uZ.ui=0x1);
else{
uint_fast16_t regime = 1;
if (regS) regime = ( (1<<reg)-1 ) <<1;
uZ.ui = ((uint16_t) (regime) << (14-reg)) + ((uint16_t) (exp)<< (13-reg)) + ((uint16_t)(frac));
//n+1 frac bit is 1. Need to check if another bit is 1 too if not round to even
if (reg==14 && exp) bitNPlusOne = 1;
uZ.ui += (bitNPlusOne & (uZ.ui&1)) | ( bitNPlusOne & bitsMore);
}
if (sign) uZ.ui = -uZ.ui & 0xFFFF;
}
}
else{
else if (f16 < 1 || f16 > -1 ){
if (sign){
//Make negative numbers positive for easier computation
f16 = -f16;
}
regS = 0;
reg = 0;
//regime
while (f16>=4){
f16 *=0.25;
while (f16<1){
f16 *= 4;
reg++;
}
if (f16>=2){
f16*=0.5;
f16/=2;
exp++;
}
int8_t fracLength = 13-reg;
//printf("f16: %.16f fracLength: %d\n", f16, fracLength);
if (fracLength<0){
//reg == 14, means rounding bits is exp and just the rest.
//printf("bitsMore: %d\n", bitsMore);
if (f16>1) bitsMore = 1;
//bitsMore = 0;
if (reg==14){
bitNPlusOne = exp;
if (frac>1) bitsMore = 1;
}
else
else{
//only possible combination for reg=15 to reach here is 7FFF (maxpos) and FFFF (-minpos)
//but since it should be caught on top, so no need to handle
uint_fast8_t fracLength = 13-reg;
frac = convertQuadFractionP16 (f16, fracLength, &bitNPlusOne, &bitsMore);
//printf("bitsNPlusOne: %d bitsMore: %d %0.15f f16:%.16f\n", bitsNPlusOne, bitsMore, a.f, f16);
//printf("sign: %d regS: %d reg: %d exp: %d frac:%d \n", sign, regS, reg, exp, frac);
//printf("----\n");
}
if (reg==14 && frac>0) {
bitsMore = 1;
frac=0;
}
if (reg>14)
(regS) ? (uZ.ui= 32767): (uZ.ui=0x1);
else{
uint_fast16_t regime = 1;
if (regS) regime = ( (1<<reg)-1 ) <<1;
uZ.ui = ((uint16_t) (regime) << (14-reg)) + ((uint16_t) (exp)<< (13-reg)) + ((uint16_t)(frac));
//n+1 frac bit is 1. Need to check if another bit is 1 too if not round to even
if (reg==14 && exp) bitNPlusOne = 1;
uZ.ui += (bitNPlusOne & (uZ.ui&1)) | ( bitNPlusOne & bitsMore);
}
if (sign) uZ.ui = -uZ.ui & 0xFFFF;
uZ.p = c_roundPackToP16(sign, regS, reg, exp, frac, bitNPlusOne, bitsMore);
}
}
else if (f16 < 1 || f16 > -1 ){
//printf("SHOULD BE HERE\n");
if (sign){
//Make negative numbers positive for easier computation
f16 = -f16;
}
regS = 0;
reg = 0;
//regime
//printf("here we go\n");
while (f16<1){
f16 *= 4;
reg++;
}
if (f16>=2){
f16/=2;
exp++;
else {
//NaR - for NaN, INF and all other combinations
uZ.ui = 0x8000;
}
//printf("f16: %.16f\n", f16);
if (reg==14){
bitNPlusOne = exp;
if (frac>1) bitsMore = 1;
}
else{
//only possible combination for reg=15 to reach here is 7FFF (maxpos) and FFFF (-minpos)
//but since it should be caught on top, so no need to handle
uint_fast8_t fracLength = 13-reg;
//printf("f16: %.26f, fracLength=%d reg: %d\n", f16, fracLength, reg);
frac = convertQuadFractionP16 (f16, fracLength, &bitNPlusOne, &bitsMore);
}
if (reg==14 && frac>0) {
bitsMore = 1;
frac=0;
}
uZ.p = c_roundPackToP16(sign, regS, reg, exp, frac, bitNPlusOne, bitsMore);
}
else {
//NaR - for NaN, INF and all other combinations
uZ.ui = 0x8000;
return uZ.p;
}
return uZ.p;
}*/
#endif
This diff is collapsed.
/*============================================================================
This C source file is part of the SoftPosit Posit Arithmetic Package
by S. H. Leong (Cerlane).
Copyright 2017, 2018 A*STAR. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions, and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=============================================================================*/
#include <math.h>
#include "platform.h"
#include "internals.h"
void checkExtraTwoBitsP8(float f8, double temp, bool * bitsNPlusOne, bool * bitsMore ){
temp /= 2;
if (temp<=f8){
*bitsNPlusOne = 1;
f8-=temp;
}
if (f8>0)
*bitsMore = 1;
}
uint_fast16_t convertFractionP8(float f8, uint_fast8_t fracLength, bool * bitsNPlusOne, bool * bitsMore ){
uint_fast8_t frac=0;
if(f8==0) return 0;
else if(f8==INFINITY) return INFINITY;
f8 -= 1; //remove hidden bit
if (fracLength==0)
checkExtraTwoBitsP8(f8, 1.0, bitsNPlusOne, bitsMore);
else{
double temp = 1;
while (true){
temp /= 2;
if (temp<=f8){
f8-=temp;
fracLength--;
frac = (frac<<1) + 1; //shift in one
if (f8==0){
//put in the rest of the bits
frac <<= (uint_fast8_t)fracLength;
break;
}
if (fracLength == 0){
checkExtraTwoBitsP8(f8, temp, bitsNPlusOne, bitsMore);
break;
}
}
else{
frac <<= 1; //shift in a zero
fracLength--;