committed by
GitHub
19 changed files with 614 additions and 5 deletions
@ -0,0 +1,36 @@ |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "specialize.h" |
|||
#include "softfloat.h" |
|||
|
|||
uint_fast16_t bf16_classify( bfloat16_t a ) |
|||
{ |
|||
union ui16_f16 uA; |
|||
uint_fast16_t uiA; |
|||
|
|||
uA.f = a; |
|||
uiA = uA.ui; |
|||
|
|||
uint_fast16_t infOrNaN = expBF16UI( uiA ) == 0xFF; |
|||
uint_fast16_t subnormalOrZero = expBF16UI( uiA ) == 0; |
|||
bool sign = signBF16UI( uiA ); |
|||
bool fracZero = fracBF16UI( uiA ) == 0; |
|||
bool isNaN = isNaNBF16UI( uiA ); |
|||
bool isSNaN = softfloat_isSigNaNBF16UI( uiA ); |
|||
|
|||
return |
|||
( sign && infOrNaN && fracZero ) << 0 | |
|||
( sign && !infOrNaN && !subnormalOrZero ) << 1 | |
|||
( sign && subnormalOrZero && !fracZero ) << 2 | |
|||
( sign && subnormalOrZero && fracZero ) << 3 | |
|||
( !sign && infOrNaN && fracZero ) << 7 | |
|||
( !sign && !infOrNaN && !subnormalOrZero ) << 6 | |
|||
( !sign && subnormalOrZero && !fracZero ) << 5 | |
|||
( !sign && subnormalOrZero && fracZero ) << 4 | |
|||
( isNaN && isSNaN ) << 8 | |
|||
( isNaN && !isSNaN ) << 9; |
|||
} |
|||
|
|||
@ -0,0 +1,65 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic |
|||
Package, Release 3d, by John R. Hauser. |
|||
|
|||
Copyright 2011, 2012, 2013, 2014, 2015 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "softfloat.h" |
|||
|
|||
bool bf16_eq( bfloat16_t a, bfloat16_t b ) |
|||
{ |
|||
float32_t f32A = { (uint_fast32_t)a.v << 16 }; |
|||
float32_t f32B = { (uint_fast32_t)b.v << 16 }; |
|||
|
|||
return f32_eq ( f32A, f32B ); |
|||
} |
|||
|
|||
bool bf16_le( bfloat16_t a, bfloat16_t b ) |
|||
{ |
|||
float32_t f32A = { (uint_fast32_t)a.v << 16 }; |
|||
float32_t f32B = { (uint_fast32_t)b.v << 16 }; |
|||
|
|||
return f32_le ( f32A, f32B ); |
|||
} |
|||
|
|||
bool bf16_lt( bfloat16_t a, bfloat16_t b ) |
|||
{ |
|||
float32_t f32A = { (uint_fast32_t)a.v << 16 }; |
|||
float32_t f32B = { (uint_fast32_t)b.v << 16 }; |
|||
|
|||
return f32_lt ( f32A, f32B ); |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic |
|||
Package, Release 3d, by John R. Hauser. |
|||
|
|||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "specialize.h" |
|||
#include "softfloat.h" |
|||
|
|||
int_fast32_t bf16_to_i32( bfloat16_t a, uint_fast8_t roundingMode, bool exact ) |
|||
{ |
|||
return f32_to_i32(bf16_to_f32(a), roundingMode, exact); |
|||
} |
|||
|
|||
@ -0,0 +1,57 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic |
|||
Package, Release 3d, by John R. Hauser. |
|||
|
|||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdint.h> |
|||
#include "specialize.h" |
|||
#include "softfloat.h" |
|||
|
|||
int_fast8_t bf16_to_i8( bfloat16_t a, uint_fast8_t roundingMode, bool exact ) |
|||
{ |
|||
uint_fast8_t old_flags = softfloat_exceptionFlags; |
|||
|
|||
int_fast32_t sig32 = bf16_to_i32(a, roundingMode, exact); |
|||
|
|||
if (sig32 > INT8_MAX) { |
|||
softfloat_exceptionFlags = old_flags | softfloat_flag_invalid; |
|||
return i8_fromPosOverflow; |
|||
} else if (sig32 < INT8_MIN) { |
|||
softfloat_exceptionFlags = old_flags | softfloat_flag_invalid; |
|||
return i8_fromNegOverflow; |
|||
} else { |
|||
return sig32; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,48 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic |
|||
Package, Release 3d, by John R. Hauser. |
|||
|
|||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "specialize.h" |
|||
#include "softfloat.h" |
|||
|
|||
uint_fast32_t bf16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact ) |
|||
{ |
|||
return f32_to_ui32(bf16_to_f32(a), roundingMode, exact); |
|||
} |
|||
|
|||
@ -0,0 +1,54 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic |
|||
Package, Release 3d, by John R. Hauser. |
|||
|
|||
Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdint.h> |
|||
#include "specialize.h" |
|||
#include "softfloat.h" |
|||
|
|||
uint_fast8_t bf16_to_ui8( bfloat16_t a, uint_fast8_t roundingMode, bool exact ) |
|||
{ |
|||
uint_fast8_t old_flags = softfloat_exceptionFlags; |
|||
|
|||
uint_fast32_t sig32 = bf16_to_ui32(a, roundingMode, exact); |
|||
|
|||
if (sig32 > UINT8_MAX) { |
|||
softfloat_exceptionFlags = old_flags | softfloat_flag_invalid; |
|||
return ui8_fromPosOverflow; |
|||
} else { |
|||
return sig32; |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,63 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdio.h> |
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "specialize.h" |
|||
#include "softfloat.h" |
|||
|
|||
bool bf16_sign( bfloat16_t a ) |
|||
{ |
|||
return signBF16UI(a.v); |
|||
} |
|||
|
|||
bool f16_sign( float16_t a ) |
|||
{ |
|||
return signF16UI(a.v); |
|||
} |
|||
|
|||
bool f32_sign( float32_t a ) |
|||
{ |
|||
return signF32UI(a.v); |
|||
} |
|||
|
|||
bool f64_sign( float64_t a ) |
|||
{ |
|||
return signF64UI(a.v); |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdbool.h> |
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "softfloat.h" |
|||
|
|||
bfloat16_t i32_to_bf16( int32_t a ) |
|||
{ |
|||
uint_fast8_t origin_rounding_mode = softfloat_roundingMode; |
|||
softfloat_roundingMode = softfloat_round_odd; |
|||
float32_t tmp_val = i32_to_f32(a); |
|||
|
|||
softfloat_roundingMode = origin_rounding_mode; |
|||
return f32_to_bf16(tmp_val); |
|||
} |
|||
|
|||
@ -0,0 +1,51 @@ |
|||
|
|||
/*============================================================================
|
|||
|
|||
This C source 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. |
|||
|
|||
=============================================================================*/ |
|||
|
|||
#include <stdint.h> |
|||
#include "platform.h" |
|||
#include "internals.h" |
|||
#include "softfloat.h" |
|||
|
|||
bfloat16_t ui32_to_bf16( uint32_t a ) |
|||
{ |
|||
uint_fast8_t origin_rounding_mode = softfloat_roundingMode; |
|||
softfloat_roundingMode = softfloat_round_odd; |
|||
float32_t tmp_val = ui32_to_f32(a); |
|||
|
|||
softfloat_roundingMode = origin_rounding_mode; |
|||
return f32_to_bf16(tmp_val); |
|||
} |
|||
|
|||
Loading…
Reference in new issue