From 498bdd7e81d8d828ade748b73417e7d8cdc940f4 Mon Sep 17 00:00:00 2001 From: Marcelo Cantos <13160581+anzdaddy@users.noreply.github.com> Date: Thu, 17 Jul 2025 12:02:25 +1000 Subject: [PATCH 1/6] intel decimal library reference tests --- d64/decimal.go | 24 +- d64/decimal_debug.go | 2 +- d64/math.go | 80 +- reftest/bid128_2_str.h | 39 + reftest/bid128_2_str_macros.h | 155 + reftest/bid128_2_str_tables.c | 648 ++++ reftest/bid64_add.c | 583 ++++ reftest/bid64_mul.c | 366 +++ reftest/bid64_string.c | 538 ++++ reftest/bid_conf.h | 2059 +++++++++++++ reftest/bid_decimal_data.c | 1325 +++++++++ reftest/bid_decimal_globals.c | 106 + reftest/bid_functions.h | 5268 +++++++++++++++++++++++++++++++++ reftest/bid_gcc_intrinsics.h | 301 ++ reftest/bid_internal.h | 2955 ++++++++++++++++++ reftest/go.mod | 14 + reftest/go.sum | 11 + reftest/reftest.go | 36 + reftest/reftest_test.go | 103 + 19 files changed, 14571 insertions(+), 42 deletions(-) create mode 100644 reftest/bid128_2_str.h create mode 100644 reftest/bid128_2_str_macros.h create mode 100644 reftest/bid128_2_str_tables.c create mode 100644 reftest/bid64_add.c create mode 100644 reftest/bid64_mul.c create mode 100644 reftest/bid64_string.c create mode 100644 reftest/bid_conf.h create mode 100644 reftest/bid_decimal_data.c create mode 100644 reftest/bid_decimal_globals.c create mode 100644 reftest/bid_functions.h create mode 100644 reftest/bid_gcc_intrinsics.h create mode 100644 reftest/bid_internal.h create mode 100644 reftest/go.mod create mode 100644 reftest/go.sum create mode 100644 reftest/reftest.go create mode 100644 reftest/reftest_test.go diff --git a/d64/decimal.go b/d64/decimal.go index 76bf07f..50859dd 100644 --- a/d64/decimal.go +++ b/d64/decimal.go @@ -539,18 +539,23 @@ func checkNan(d, e Decimal, dp, ep *decParts) (Decimal, bool) { ep.fl = e.flavor() switch { case dp.fl == flSNaN: - return d, true case ep.fl == flSNaN: - return e, true + d = e case dp.fl == flQNaN: - return d, true case ep.fl == flQNaN: - return e, true + d = e default: dp.unpackV2(d) ep.unpackV2(e) return Decimal{}, false } + return d.qNan(), true +} + +func (d Decimal) qNan() Decimal { + // Remove the exponent bits from the NaN. + // This is a hack to make sure that the NaN is not interpreted as a normal number. + return newDec(d.bits &^ (0xff << 50)) } // checkNan3 returns the decimal NaN that is to be propogated and true else first decimal and false @@ -560,21 +565,20 @@ func checkNan3(d, e, f Decimal, dp, ep, fp *decParts) (Decimal, bool) { fp.fl = f.flavor() switch { case dp.fl == flSNaN: - return d, true case ep.fl == flSNaN: - return e, true + d = e case fp.fl == flSNaN: - return f, true + d = f case dp.fl == flQNaN: - return d, true case ep.fl == flQNaN: - return e, true + d = e case fp.fl == flQNaN: - return f, true + d = f default: dp.unpackV2(d) ep.unpackV2(e) fp.unpackV2(f) return Decimal{}, false } + return d.qNan(), true } diff --git a/d64/decimal_debug.go b/d64/decimal_debug.go index 98e2840..3b4d16b 100644 --- a/d64/decimal_debug.go +++ b/d64/decimal_debug.go @@ -9,12 +9,12 @@ import "fmt" // It uses the binary representation method. // Decimal is intentionally a struct to ensure users don't accidentally cast it to uint64. type Decimal struct { + bits uint64 s string fl flavor sign int8 exp int16 significand uint64 - bits uint64 } func newDec(bits uint64) Decimal { diff --git a/d64/math.go b/d64/math.go index 881773c..409e592 100644 --- a/d64/math.go +++ b/d64/math.go @@ -317,16 +317,21 @@ func (ctx Context) Add(d, e Decimal) Decimal { } if dp.fl == flInf || ep.fl == flInf { if dp.fl != flInf { - return e + return e.noSigInf() } if ep.fl != flInf || ep.sign == dp.sign { - return d + return d.noSigInf() } return QNaN } return ctx.add(d, e, &dp, &ep) } +// noSigInf returns the same inf but with all ignored bits set to zero. +func (d Decimal) noSigInf() Decimal { + return newDec(d.bits &^ ((1 << (64 - 1 - 5)) - 1)) +} + // Add computes d + e func (ctx Context) add(d, e Decimal, dp, ep *decParts) Decimal { if dp.significand.lo == 0 { @@ -334,42 +339,55 @@ func (ctx Context) add(d, e Decimal, dp, ep *decParts) Decimal { } else if ep.significand.lo == 0 { return d } - sep := dp.exp - ep.exp - if sep < -17 { - return e - } - if sep < 0 { - dp, ep = ep, dp - sep = -sep - } - if sep > 17 { - return d - } - var rndStatus discardedDigit var ans decParts + + sep := dp.exp - ep.exp switch { - case sep == 0: - ans.add64(dp, ep) - case sep < 4: - dp.significand.lo *= tenToThe[sep] - dp.exp -= sep - ans.add64(dp, ep) + case sep < -17: + ans = *ep + case sep > 17: + ans = *dp default: - dp.significand.mul64(&dp.significand, tenToThe[17]) - dp.exp -= 17 - ep.significand.mul64(&ep.significand, tenToThe[17-sep]) - ep.exp -= 17 - sep - ans.add128V2(dp, ep) + if sep < 0 { + dp, ep = ep, dp + sep = -sep + } + var rndStatus discardedDigit + switch { + case sep == 0: + ans.add64(dp, ep) + case sep < 4: + dp.significand.lo *= tenToThe[sep] + dp.exp -= sep + ans.add64(dp, ep) + default: + dp.significand.mul64(&dp.significand, tenToThe[17]) + dp.exp -= 17 + ep.significand.mul64(&ep.significand, tenToThe[17-sep]) + ep.exp -= 17 - sep + ans.add128V2(dp, ep) + } + rndStatus = ans.roundToLo() + if ans.exp < -expOffset { + rndStatus = ans.rescale(-expOffset) + } + ans.significand.lo = ctx.Rounding.round(ans.significand.lo, rndStatus) } - rndStatus = ans.roundToLo() - if ans.exp < -expOffset { - rndStatus = ans.rescale(-expOffset) + + prefexp := min(dp.exp, ep.exp) + // TODO: replace O(n) loops with O(1) or O(log n) rescaling. + for ans.exp < prefexp && ans.significand.lo%10 == 0 { + ans.significand.lo /= 10 + ans.exp++ } - ans.significand.lo = ctx.Rounding.round(ans.significand.lo, rndStatus) - if ans.significand.lo != 0 { - ans.exp, ans.significand.lo = renormalize(ans.exp, ans.significand.lo) + for ans.exp > prefexp && ans.significand.lo < decimalBase { + ans.significand.lo *= 10 + ans.exp-- } + // if ans.significand.lo != 0 { + // ans.exp, ans.significand.lo = renormalize(ans.exp, ans.significand.lo) + // } if ans.exp > expMax || ans.significand.lo > maxSig { return infinities[ans.sign] } diff --git a/reftest/bid128_2_str.h b/reftest/bid128_2_str.h new file mode 100644 index 0000000..d3dcc28 --- /dev/null +++ b/reftest/bid128_2_str.h @@ -0,0 +1,39 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +BID_EXTERN_C BID_UINT64 bid_Twoto60_m_10to18; +BID_EXTERN_C BID_UINT64 bid_Twoto60; +BID_EXTERN_C BID_UINT64 bid_Inv_Tento9; +BID_EXTERN_C BID_UINT32 bid_Twoto30_m_10to9; +BID_EXTERN_C BID_UINT32 bid_Tento9; +BID_EXTERN_C BID_UINT32 bid_Tento6; +BID_EXTERN_C BID_UINT32 bid_Tento3; + +BID_EXTERN_C const char bid_midi_tbl[1000][3]; +BID_EXTERN_C const BID_UINT64 mod10_18_tbl[9][128]; diff --git a/reftest/bid128_2_str_macros.h b/reftest/bid128_2_str_macros.h new file mode 100644 index 0000000..cae3f24 --- /dev/null +++ b/reftest/bid128_2_str_macros.h @@ -0,0 +1,155 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 __L0_Normalize_10to18( X_hi, X_lo ) \ +{ \ +BID_UINT64 L0_tmp; \ +L0_tmp = (X_lo) + bid_Twoto60_m_10to18; \ +if (L0_tmp & bid_Twoto60) \ + {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<4)>>4);} \ +} + + +#define __L0_Normalize_10to9( X_hi, X_lo ) \ +{ \ +BID_UINT32 L0_tmp; \ +L0_tmp = (X_lo) + bid_Twoto30_m_10to9; \ +if (L0_tmp & 0x40000000) \ + {(X_hi)=(X_hi)+1;(X_lo)=((L0_tmp<<2)>>2);} \ +} + + +#define __L0_Split_MiDi_2( X, ptr ) \ +{ \ +BID_UINT32 L0_head, L0_tail, L0_tmp; \ + L0_head = (X) >> 10; \ + L0_tail = ((X)&(0x03FF))+(L0_head<<5)-(L0_head<<3); \ + L0_tmp = (L0_tail)>>10; L0_head += L0_tmp; \ + L0_tail = (L0_tail&(0x03FF))+(L0_tmp<<5)-(L0_tmp<<3); \ + if (L0_tail > 999){L0_tail -= 1000; L0_head += 1;} \ + *((ptr)++) = L0_head; *((ptr)++) = L0_tail; \ +} + + +#define __L0_Split_MiDi_3( X, ptr ) \ +{ \ +BID_UINT32 L0_X, L0_head, L0_mid, L0_tail, L0_tmp; \ + L0_X = (BID_UINT32)((X)); \ + L0_head = ((L0_X>>17)*34359)>>18; \ + L0_X -= L0_head*1000000; \ + if (L0_X >= 1000000){L0_X -= 1000000;L0_head+=1;} \ + L0_mid = L0_X >> 10; \ + L0_tail = (L0_X & (0x03FF))+(L0_mid<<5)-(L0_mid<<3); \ + L0_tmp = (L0_tail)>>10; L0_mid += L0_tmp; \ + L0_tail = (L0_tail&(0x3FF))+(L0_tmp<<5)-(L0_tmp<<3); \ + if (L0_tail>999){L0_tail-=1000;L0_mid+=1;} \ + *((ptr)++)=L0_head;*((ptr)++)=L0_mid; \ + *((ptr)++)=L0_tail; \ +} + +#define __L1_Split_MiDi_6( X, ptr ) \ +{ \ +BID_UINT32 L1_X_hi, L1_X_lo; \ +BID_UINT64 L1_Xhi_64, L1_Xlo_64; \ +L1_Xhi_64 = ( ((X)>>28)*bid_Inv_Tento9 ) >> 33; \ +L1_Xlo_64 = (X) - L1_Xhi_64*(BID_UINT64)bid_Tento9; \ +if (L1_Xlo_64 >= (BID_UINT64)bid_Tento9) \ + {L1_Xlo_64-=(BID_UINT64)bid_Tento9;L1_Xhi_64+=1;} \ +L1_X_hi=(BID_UINT32)L1_Xhi_64; L1_X_lo=(BID_UINT32)L1_Xlo_64; \ +__L0_Split_MiDi_3(L1_X_hi,(ptr)); \ +__L0_Split_MiDi_3(L1_X_lo,(ptr)); \ +} + +#define __L1_Split_MiDi_6_Lead( X, ptr ) \ +{ \ +BID_UINT32 L1_X_hi, L1_X_lo; \ +BID_UINT64 L1_Xhi_64, L1_Xlo_64; \ +if ((X)>=(BID_UINT64)bid_Tento9){ \ + L1_Xhi_64 = ( ((X)>>28)*bid_Inv_Tento9 ) >> 33; \ + L1_Xlo_64 = (X) - L1_Xhi_64*(BID_UINT64)bid_Tento9; \ + if (L1_Xlo_64 >= (BID_UINT64)bid_Tento9) \ + {L1_Xlo_64-=(BID_UINT64)bid_Tento9;L1_Xhi_64+=1;} \ + L1_X_hi=(BID_UINT32)L1_Xhi_64; \ + L1_X_lo=(BID_UINT32)L1_Xlo_64; \ + if (L1_X_hi>=bid_Tento6){ \ + __L0_Split_MiDi_3(L1_X_hi,(ptr)); \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ + else if (L1_X_hi>=bid_Tento3){ \ + __L0_Split_MiDi_2(L1_X_hi,(ptr)); \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ + else { \ + *((ptr)++) = L1_X_hi; \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ +} \ +else { \ + L1_X_lo = (BID_UINT32)(X); \ + if (L1_X_lo>=bid_Tento6){ \ + __L0_Split_MiDi_3(L1_X_lo,(ptr)); \ + } \ + else if (L1_X_lo>=bid_Tento3){ \ + __L0_Split_MiDi_2(L1_X_lo,(ptr)); \ + } \ + else { \ + *((ptr)++) = L1_X_lo; \ + } \ +} \ +} + + +#define __L0_MiDi2Str( X, c_ptr ) \ +{ \ +const char *L0_src; \ + L0_src = bid_midi_tbl[(X)]; \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src); \ +} + +#define __L0_MiDi2Str_Lead( X, c_ptr ) \ +{ \ +const char *L0_src; \ + L0_src = bid_midi_tbl[(X)]; \ + if ((X)>=100){ \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src); \ + } \ + else if ((X)>=10){ \ + L0_src++; \ + *((c_ptr)++) = *(L0_src++); \ + *((c_ptr)++) = *(L0_src); \ + } \ + else { \ + L0_src++;L0_src++; \ + *((c_ptr)++) = *(L0_src); \ +} \ +} diff --git a/reftest/bid128_2_str_tables.c b/reftest/bid128_2_str_tables.c new file mode 100644 index 0000000..9fe826a --- /dev/null +++ b/reftest/bid128_2_str_tables.c @@ -0,0 +1,648 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 "bid_internal.h" + +BID_UINT64 bid_Twoto60_m_10to18 = 152921504606846976LL; +BID_UINT64 bid_Twoto60 = 0x1000000000000000LL; +BID_UINT64 bid_Inv_Tento9 = 2305843009LL; /* floor(2^61/10^9) */ +BID_UINT32 bid_Twoto30_m_10to9 = 73741824; +BID_UINT32 bid_Tento9 = 1000000000; +BID_UINT32 bid_Tento6 = 1000000; +BID_UINT32 bid_Tento3 = 1000; + +const char bid_midi_tbl[1000][3] = { + "000", "001", "002", "003", "004", "005", "006", "007", "008", "009", + "010", "011", "012", "013", "014", "015", "016", "017", "018", "019", + "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", + "030", "031", "032", "033", "034", "035", "036", "037", "038", "039", + "040", "041", "042", "043", "044", "045", "046", "047", "048", "049", + "050", "051", "052", "053", "054", "055", "056", "057", "058", "059", + "060", "061", "062", "063", "064", "065", "066", "067", "068", "069", + "070", "071", "072", "073", "074", "075", "076", "077", "078", "079", + "080", "081", "082", "083", "084", "085", "086", "087", "088", "089", + "090", "091", "092", "093", "094", "095", "096", "097", "098", "099", + "100", "101", "102", "103", "104", "105", "106", "107", "108", "109", + "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", + "120", "121", "122", "123", "124", "125", "126", "127", "128", "129", + "130", "131", "132", "133", "134", "135", "136", "137", "138", "139", + "140", "141", "142", "143", "144", "145", "146", "147", "148", "149", + "150", "151", "152", "153", "154", "155", "156", "157", "158", "159", + "160", "161", "162", "163", "164", "165", "166", "167", "168", "169", + "170", "171", "172", "173", "174", "175", "176", "177", "178", "179", + "180", "181", "182", "183", "184", "185", "186", "187", "188", "189", + "190", "191", "192", "193", "194", "195", "196", "197", "198", "199", + "200", "201", "202", "203", "204", "205", "206", "207", "208", "209", + "210", "211", "212", "213", "214", "215", "216", "217", "218", "219", + "220", "221", "222", "223", "224", "225", "226", "227", "228", "229", + "230", "231", "232", "233", "234", "235", "236", "237", "238", "239", + "240", "241", "242", "243", "244", "245", "246", "247", "248", "249", + "250", "251", "252", "253", "254", "255", "256", "257", "258", "259", + "260", "261", "262", "263", "264", "265", "266", "267", "268", "269", + "270", "271", "272", "273", "274", "275", "276", "277", "278", "279", + "280", "281", "282", "283", "284", "285", "286", "287", "288", "289", + "290", "291", "292", "293", "294", "295", "296", "297", "298", "299", + "300", "301", "302", "303", "304", "305", "306", "307", "308", "309", + "310", "311", "312", "313", "314", "315", "316", "317", "318", "319", + "320", "321", "322", "323", "324", "325", "326", "327", "328", "329", + "330", "331", "332", "333", "334", "335", "336", "337", "338", "339", + "340", "341", "342", "343", "344", "345", "346", "347", "348", "349", + "350", "351", "352", "353", "354", "355", "356", "357", "358", "359", + "360", "361", "362", "363", "364", "365", "366", "367", "368", "369", + "370", "371", "372", "373", "374", "375", "376", "377", "378", "379", + "380", "381", "382", "383", "384", "385", "386", "387", "388", "389", + "390", "391", "392", "393", "394", "395", "396", "397", "398", "399", + "400", "401", "402", "403", "404", "405", "406", "407", "408", "409", + "410", "411", "412", "413", "414", "415", "416", "417", "418", "419", + "420", "421", "422", "423", "424", "425", "426", "427", "428", "429", + "430", "431", "432", "433", "434", "435", "436", "437", "438", "439", + "440", "441", "442", "443", "444", "445", "446", "447", "448", "449", + "450", "451", "452", "453", "454", "455", "456", "457", "458", "459", + "460", "461", "462", "463", "464", "465", "466", "467", "468", "469", + "470", "471", "472", "473", "474", "475", "476", "477", "478", "479", + "480", "481", "482", "483", "484", "485", "486", "487", "488", "489", + "490", "491", "492", "493", "494", "495", "496", "497", "498", "499", + "500", "501", "502", "503", "504", "505", "506", "507", "508", "509", + "510", "511", "512", "513", "514", "515", "516", "517", "518", "519", + "520", "521", "522", "523", "524", "525", "526", "527", "528", "529", + "530", "531", "532", "533", "534", "535", "536", "537", "538", "539", + "540", "541", "542", "543", "544", "545", "546", "547", "548", "549", + "550", "551", "552", "553", "554", "555", "556", "557", "558", "559", + "560", "561", "562", "563", "564", "565", "566", "567", "568", "569", + "570", "571", "572", "573", "574", "575", "576", "577", "578", "579", + "580", "581", "582", "583", "584", "585", "586", "587", "588", "589", + "590", "591", "592", "593", "594", "595", "596", "597", "598", "599", + "600", "601", "602", "603", "604", "605", "606", "607", "608", "609", + "610", "611", "612", "613", "614", "615", "616", "617", "618", "619", + "620", "621", "622", "623", "624", "625", "626", "627", "628", "629", + "630", "631", "632", "633", "634", "635", "636", "637", "638", "639", + "640", "641", "642", "643", "644", "645", "646", "647", "648", "649", + "650", "651", "652", "653", "654", "655", "656", "657", "658", "659", + "660", "661", "662", "663", "664", "665", "666", "667", "668", "669", + "670", "671", "672", "673", "674", "675", "676", "677", "678", "679", + "680", "681", "682", "683", "684", "685", "686", "687", "688", "689", + "690", "691", "692", "693", "694", "695", "696", "697", "698", "699", + "700", "701", "702", "703", "704", "705", "706", "707", "708", "709", + "710", "711", "712", "713", "714", "715", "716", "717", "718", "719", + "720", "721", "722", "723", "724", "725", "726", "727", "728", "729", + "730", "731", "732", "733", "734", "735", "736", "737", "738", "739", + "740", "741", "742", "743", "744", "745", "746", "747", "748", "749", + "750", "751", "752", "753", "754", "755", "756", "757", "758", "759", + "760", "761", "762", "763", "764", "765", "766", "767", "768", "769", + "770", "771", "772", "773", "774", "775", "776", "777", "778", "779", + "780", "781", "782", "783", "784", "785", "786", "787", "788", "789", + "790", "791", "792", "793", "794", "795", "796", "797", "798", "799", + "800", "801", "802", "803", "804", "805", "806", "807", "808", "809", + "810", "811", "812", "813", "814", "815", "816", "817", "818", "819", + "820", "821", "822", "823", "824", "825", "826", "827", "828", "829", + "830", "831", "832", "833", "834", "835", "836", "837", "838", "839", + "840", "841", "842", "843", "844", "845", "846", "847", "848", "849", + "850", "851", "852", "853", "854", "855", "856", "857", "858", "859", + "860", "861", "862", "863", "864", "865", "866", "867", "868", "869", + "870", "871", "872", "873", "874", "875", "876", "877", "878", "879", + "880", "881", "882", "883", "884", "885", "886", "887", "888", "889", + "890", "891", "892", "893", "894", "895", "896", "897", "898", "899", + "900", "901", "902", "903", "904", "905", "906", "907", "908", "909", + "910", "911", "912", "913", "914", "915", "916", "917", "918", "919", + "920", "921", "922", "923", "924", "925", "926", "927", "928", "929", + "930", "931", "932", "933", "934", "935", "936", "937", "938", "939", + "940", "941", "942", "943", "944", "945", "946", "947", "948", "949", + "950", "951", "952", "953", "954", "955", "956", "957", "958", "959", + "960", "961", "962", "963", "964", "965", "966", "967", "968", "969", + "970", "971", "972", "973", "974", "975", "976", "977", "978", "979", + "980", "981", "982", "983", "984", "985", "986", "987", "988", "989", + "990", "991", "992", "993", "994", "995", "996", "997", "998", "999" +}; + +const BID_UINT64 mod10_18_tbl[9][128] = { + // 2^59 = 576460752303423488, A and B breakdown, where data = A*10^18 + B + + { + 0LL, 0LL, 0LL, 576460752303423488LL, + // 0*2^59, 1*2^59 + 1LL, 152921504606846976LL, 1LL, 729382256910270464LL, + // 2*2^59, 3*2^59 + 2LL, 305843009213693952LL, 2LL, 882303761517117440LL, + // 4*2^59, 5*2^59 + 3LL, 458764513820540928LL, 4LL, 35225266123964416LL, + // 6*2^59, 7*2^59 + 4LL, 611686018427387904LL, 5LL, 188146770730811392LL, + // 8*2^59, 9*2^59 + 5LL, 764607523034234880LL, 6LL, 341068275337658368LL, + // 10*2^59, 11*2^59 + 6LL, 917529027641081856LL, 7LL, 493989779944505344LL, + // 12*2^59, 13*2^59 + 8LL, 70450532247928832LL, 8LL, 646911284551352320LL, + // 14*2^59, 15*2^59 + 9LL, 223372036854775808LL, 9LL, 799832789158199296LL, + // 16*2^59, 17*2^59 + 10LL, 376293541461622784LL, 10LL, 952754293765046272LL, + // 18*2^59, 19*2^59 + 11LL, 529215046068469760LL, 12LL, 105675798371893248LL, + // 20*2^59, 21*2^59 + 12LL, 682136550675316736LL, 13LL, 258597302978740224LL, + // 22*2^59, 23*2^59 + 13LL, 835058055282163712LL, 14LL, 411518807585587200LL, + // 24*2^59, 25*2^59 + 14LL, 987979559889010688LL, 15LL, 564440312192434176LL, + // 26*2^59, 27*2^59 + 16LL, 140901064495857664LL, 16LL, 717361816799281152LL, + // 28*2^59, 29*2^59 + 17LL, 293822569102704640LL, 17LL, 870283321406128128LL, + // 30*2^59, 31*2^59 + 18LL, 446744073709551616LL, 19LL, 23204826012975104LL, + // 32*2^59, 33*2^59 + 19LL, 599665578316398592LL, 20LL, 176126330619822080LL, + // 34*2^59, 35*2^59 + 20LL, 752587082923245568LL, 21LL, 329047835226669056LL, + // 36*2^59, 37*2^59 + 21LL, 905508587530092544LL, 22LL, 481969339833516032LL, + // 38*2^59, 39*2^59 + 23LL, 58430092136939520LL, 23LL, 634890844440363008LL, + // 40*2^59, 41*2^59 + 24LL, 211351596743786496LL, 24LL, 787812349047209984LL, + // 42*2^59, 43*2^59 + 25LL, 364273101350633472LL, 25LL, 940733853654056960LL, + // 44*2^59, 45*2^59 + 26LL, 517194605957480448LL, 27LL, 93655358260903936LL, + // 46*2^59, 47*2^59 + 27LL, 670116110564327424LL, 28LL, 246576862867750912LL, + // 48*2^59, 49*2^59 + 28LL, 823037615171174400LL, 29LL, 399498367474597888LL, + // 50*2^59, 51*2^59 + 29LL, 975959119778021376LL, 30LL, 552419872081444864LL, + // 52*2^59, 53*2^59 + 31LL, 128880624384868352LL, 31LL, 705341376688291840LL, + // 54*2^59, 55*2^59 + 32LL, 281802128991715328LL, 32LL, 858262881295138816LL, + // 56*2^59, 57*2^59 + 33LL, 434723633598562304LL, 34LL, 11184385901985792LL, + // 58*2^59, 59*2^59 + 34LL, 587645138205409280LL, 35LL, 164105890508832768LL, + // 60*2^59, 61*2^59 + 35LL, 740566642812256256LL, 36LL, 317027395115679744LL, + // 62*2^59, 63*2^59 + }, + + { + // 2^65 = 36*10^18 + 893488147419103232 + 0LL, 0LL, 36LL, 893488147419103232LL, + // 0*2^65, 1*2^65 + 73LL, 786976294838206464LL, 110LL, 680464442257309696LL, + // 2*2^65, 3*2^65 + 147LL, 573952589676412928LL, 184LL, 467440737095516160LL, + // 4*2^65, 5*2^65 + 221LL, 360928884514619392LL, 258LL, 254417031933722624LL, + // 6*2^65, 7*2^65 + 295LL, 147905179352825856LL, 332LL, 41393326771929088LL, + // 8*2^65, 9*2^65 + 368LL, 934881474191032320LL, 405LL, 828369621610135552LL, + // 0*2^65, 1*2^65 + 442LL, 721857769029238784LL, 479LL, 615345916448342016LL, + // 2*2^65, 3*2^65 + 516LL, 508834063867445248LL, 553LL, 402322211286548480LL, + // 4*2^65, 5*2^65 + 590LL, 295810358705651712LL, 627LL, 189298506124754944LL, + // 6*2^65, 7*2^65 + 664LL, 82786653543858176LL, 700LL, 976274800962961408LL, + // 8*2^65, 9*2^65 + 737LL, 869762948382064640LL, 774LL, 763251095801167872LL, + // 0*2^65, 1*2^65 + 811LL, 656739243220271104LL, 848LL, 550227390639374336LL, + // 2*2^65, 3*2^65 + 885LL, 443715538058477568LL, 922LL, 337203685477580800LL, + // 4*2^65, 5*2^65 + 959LL, 230691832896684032LL, 996LL, 124179980315787264LL, + // 6*2^65, 7*2^65 + 1033LL, 17668127734890496LL, 1069LL, 911156275153993728LL, + // 8*2^65, 9*2^65 + 1106LL, 804644422573096960LL, 1143LL, 698132569992200192LL, + // 0*2^65, 1*2^65 + 1180LL, 591620717411303424LL, 1217LL, 485108864830406656LL, + // 2*2^65, 3*2^65 + 1254LL, 378597012249509888LL, 1291LL, 272085159668613120LL, + // 4*2^65, 5*2^65 + 1328LL, 165573307087716352LL, 1365LL, 59061454506819584LL, + // 6*2^65, 7*2^65 + 1401LL, 952549601925922816LL, 1438LL, 846037749345026048LL, + // 8*2^65, 9*2^65 + 1475LL, 739525896764129280LL, 1512LL, 633014044183232512LL, + // 0*2^65, 1*2^65 + 1549LL, 526502191602335744LL, 1586LL, 419990339021438976LL, + // 2*2^65, 3*2^65 + 1623LL, 313478486440542208LL, 1660LL, 206966633859645440LL, + // 4*2^65, 5*2^65 + 1697LL, 100454781278748672LL, 1733LL, 993942928697851904LL, + // 6*2^65, 7*2^65 + 1770LL, 887431076116955136LL, 1807LL, 780919223536058368LL, + // 8*2^65, 9*2^65 + 1844LL, 674407370955161600LL, 1881LL, 567895518374264832LL, + // 0*2^65, 1*2^65 + 1918LL, 461383665793368064LL, 1955LL, 354871813212471296LL, + // 2*2^65, 3*2^65 + 1992LL, 248359960631574528LL, 2029LL, 141848108050677760LL, + // 4*2^65, 5*2^65 + 2066LL, 35336255469780992LL, 2102LL, 928824402888884224LL, + // 6*2^65, 7*2^65 + 2139LL, 822312550307987456LL, 2176LL, 715800697727090688LL, + // 8*2^65, 9*2^65 + 2213LL, 609288845146193920LL, 2250LL, 502776992565297152LL, + // 0*2^65, 1*2^65 + 2287LL, 396265139984400384LL, 2324LL, 289753287403503616LL, + // 2*2^65, 3*2^65 + }, + + { + 0LL, 0LL, 2361LL, 183241434822606848LL, + 4722LL, 366482869645213696LL, 7083LL, 549724304467820544LL, + 9444LL, 732965739290427392LL, 11805LL, 916207174113034240LL, + 14167LL, 99448608935641088LL, 16528LL, 282690043758247936LL, + 18889LL, 465931478580854784LL, 21250LL, 649172913403461632LL, + 23611LL, 832414348226068480LL, 25973LL, 15655783048675328LL, + 28334LL, 198897217871282176LL, 30695LL, 382138652693889024LL, + 33056LL, 565380087516495872LL, 35417LL, 748621522339102720LL, + 37778LL, 931862957161709568LL, 40140LL, 115104391984316416LL, + 42501LL, 298345826806923264LL, 44862LL, 481587261629530112LL, + 47223LL, 664828696452136960LL, 49584LL, 848070131274743808LL, + 51946LL, 31311566097350656LL, 54307LL, 214553000919957504LL, + 56668LL, 397794435742564352LL, 59029LL, 581035870565171200LL, + 61390LL, 764277305387778048LL, 63751LL, 947518740210384896LL, + 66113LL, 130760175032991744LL, 68474LL, 314001609855598592LL, + 70835LL, 497243044678205440LL, 73196LL, 680484479500812288LL, + 75557LL, 863725914323419136LL, 77919LL, 46967349146025984LL, + 80280LL, 230208783968632832LL, 82641LL, 413450218791239680LL, + 85002LL, 596691653613846528LL, 87363LL, 779933088436453376LL, + 89724LL, 963174523259060224LL, 92086LL, 146415958081667072LL, + 94447LL, 329657392904273920LL, 96808LL, 512898827726880768LL, + 99169LL, 696140262549487616LL, 101530LL, 879381697372094464LL, + 103892LL, 62623132194701312LL, 106253LL, 245864567017308160LL, + 108614LL, 429106001839915008LL, 110975LL, 612347436662521856LL, + 113336LL, 795588871485128704LL, 115697LL, 978830306307735552LL, + 118059LL, 162071741130342400LL, 120420LL, 345313175952949248LL, + 122781LL, 528554610775556096LL, 125142LL, 711796045598162944LL, + 127503LL, 895037480420769792LL, 129865LL, 78278915243376640LL, + 132226LL, 261520350065983488LL, 134587LL, 444761784888590336LL, + 136948LL, 628003219711197184LL, 139309LL, 811244654533804032LL, + 141670LL, 994486089356410880LL, 144032LL, 177727524179017728LL, + 146393LL, 360968959001624576LL, 148754LL, 544210393824231424LL, + }, + + { + 0LL, 0LL, 151115LL, 727451828646838272LL, + 302231LL, 454903657293676544LL, 453347LL, 182355485940514816LL, + 604462LL, 909807314587353088LL, 755578LL, 637259143234191360LL, + 906694LL, 364710971881029632LL, 1057810LL, 92162800527867904LL, + 1208925LL, 819614629174706176LL, 1360041LL, 547066457821544448LL, + 1511157LL, 274518286468382720LL, 1662273LL, 1970115115220992LL, + 1813388LL, 729421943762059264LL, 1964504LL, 456873772408897536LL, + 2115620LL, 184325601055735808LL, 2266735LL, 911777429702574080LL, + 2417851LL, 639229258349412352LL, 2568967LL, 366681086996250624LL, + 2720083LL, 94132915643088896LL, 2871198LL, 821584744289927168LL, + 3022314LL, 549036572936765440LL, 3173430LL, 276488401583603712LL, + 3324546LL, 3940230230441984LL, 3475661LL, 731392058877280256LL, + 3626777LL, 458843887524118528LL, 3777893LL, 186295716170956800LL, + 3929008LL, 913747544817795072LL, 4080124LL, 641199373464633344LL, + 4231240LL, 368651202111471616LL, 4382356LL, 96103030758309888LL, + 4533471LL, 823554859405148160LL, 4684587LL, 551006688051986432LL, + 4835703LL, 278458516698824704LL, 4986819LL, 5910345345662976LL, + 5137934LL, 733362173992501248LL, 5289050LL, 460814002639339520LL, + 5440166LL, 188265831286177792LL, 5591281LL, 915717659933016064LL, + 5742397LL, 643169488579854336LL, 5893513LL, 370621317226692608LL, + 6044629LL, 98073145873530880LL, 6195744LL, 825524974520369152LL, + 6346860LL, 552976803167207424LL, 6497976LL, 280428631814045696LL, + 6649092LL, 7880460460883968LL, 6800207LL, 735332289107722240LL, + 6951323LL, 462784117754560512LL, 7102439LL, 190235946401398784LL, + 7253554LL, 917687775048237056LL, 7404670LL, 645139603695075328LL, + 7555786LL, 372591432341913600LL, 7706902LL, 100043260988751872LL, + 7858017LL, 827495089635590144LL, 8009133LL, 554946918282428416LL, + 8160249LL, 282398746929266688LL, 8311365LL, 9850575576104960LL, + 8462480LL, 737302404222943232LL, 8613596LL, 464754232869781504LL, + 8764712LL, 192206061516619776LL, 8915827LL, 919657890163458048LL, + 9066943LL, 647109718810296320LL, 9218059LL, 374561547457134592LL, + 9369175LL, 102013376103972864LL, 9520290LL, 829465204750811136LL, + }, + + { + 0LL, 0LL, 9671406LL, 556917033397649408LL, + 19342813LL, 113834066795298816LL, 29014219LL, 670751100192948224LL, + 38685626LL, 227668133590597632LL, 48357032LL, 784585166988247040LL, + 58028439LL, 341502200385896448LL, 67699845LL, 898419233783545856LL, + 77371252LL, 455336267181195264LL, 87042659LL, 12253300578844672LL, + 96714065LL, 569170333976494080LL, 106385472LL, 126087367374143488LL, + 116056878LL, 683004400771792896LL, 125728285LL, 239921434169442304LL, + 135399691LL, 796838467567091712LL, 145071098LL, 353755500964741120LL, + 154742504LL, 910672534362390528LL, 164413911LL, 467589567760039936LL, + 174085318LL, 24506601157689344LL, 183756724LL, 581423634555338752LL, + 193428131LL, 138340667952988160LL, 203099537LL, 695257701350637568LL, + 212770944LL, 252174734748286976LL, 222442350LL, 809091768145936384LL, + 232113757LL, 366008801543585792LL, 241785163LL, 922925834941235200LL, + 251456570LL, 479842868338884608LL, 261127977LL, 36759901736534016LL, + 270799383LL, 593676935134183424LL, 280470790LL, 150593968531832832LL, + 290142196LL, 707511001929482240LL, 299813603LL, 264428035327131648LL, + 309485009LL, 821345068724781056LL, 319156416LL, 378262102122430464LL, + 328827822LL, 935179135520079872LL, 338499229LL, 492096168917729280LL, + 348170636LL, 49013202315378688LL, 357842042LL, 605930235713028096LL, + 367513449LL, 162847269110677504LL, 377184855LL, 719764302508326912LL, + 386856262LL, 276681335905976320LL, 396527668LL, 833598369303625728LL, + 406199075LL, 390515402701275136LL, 415870481LL, 947432436098924544LL, + 425541888LL, 504349469496573952LL, 435213295LL, 61266502894223360LL, + 444884701LL, 618183536291872768LL, 454556108LL, 175100569689522176LL, + 464227514LL, 732017603087171584LL, 473898921LL, 288934636484820992LL, + 483570327LL, 845851669882470400LL, 493241734LL, 402768703280119808LL, + 502913140LL, 959685736677769216LL, 512584547LL, 516602770075418624LL, + 522255954LL, 73519803473068032LL, 531927360LL, 630436836870717440LL, + 541598767LL, 187353870268366848LL, 551270173LL, 744270903666016256LL, + 560941580LL, 301187937063665664LL, 570612986LL, 858104970461315072LL, + 580284393LL, 415022003858964480LL, 589955799LL, 971939037256613888LL, + 599627206LL, 528856070654263296LL, 609298613LL, 85773104051912704LL, + }, + + { + 0LL, 0LL, 618970019LL, 642690137449562112LL, + 1237940039LL, 285380274899124224LL, 1856910058LL, + 928070412348686336LL, + 2475880078LL, 570760549798248448LL, 3094850098LL, + 213450687247810560LL, + 3713820117LL, 856140824697372672LL, 4332790137LL, + 498830962146934784LL, + 4951760157LL, 141521099596496896LL, 5570730176LL, + 784211237046059008LL, + 6189700196LL, 426901374495621120LL, 6808670216LL, + 69591511945183232LL, + 7427640235LL, 712281649394745344LL, 8046610255LL, + 354971786844307456LL, + 8665580274LL, 997661924293869568LL, 9284550294LL, + 640352061743431680LL, + 9903520314LL, 283042199192993792LL, 10522490333LL, + 925732336642555904LL, + 11141460353LL, 568422474092118016LL, 11760430373LL, + 211112611541680128LL, + 12379400392LL, 853802748991242240LL, 12998370412LL, + 496492886440804352LL, + 13617340432LL, 139183023890366464LL, 14236310451LL, + 781873161339928576LL, + 14855280471LL, 424563298789490688LL, 15474250491LL, + 67253436239052800LL, + 16093220510LL, 709943573688614912LL, 16712190530LL, + 352633711138177024LL, + 17331160549LL, 995323848587739136LL, 17950130569LL, + 638013986037301248LL, + 18569100589LL, 280704123486863360LL, 19188070608LL, + 923394260936425472LL, + 19807040628LL, 566084398385987584LL, 20426010648LL, + 208774535835549696LL, + 21044980667LL, 851464673285111808LL, 21663950687LL, + 494154810734673920LL, + 22282920707LL, 136844948184236032LL, 22901890726LL, + 779535085633798144LL, + 23520860746LL, 422225223083360256LL, 24139830766LL, + 64915360532922368LL, + 24758800785LL, 707605497982484480LL, 25377770805LL, + 350295635432046592LL, + 25996740824LL, 992985772881608704LL, 26615710844LL, + 635675910331170816LL, + 27234680864LL, 278366047780732928LL, 27853650883LL, + 921056185230295040LL, + 28472620903LL, 563746322679857152LL, 29091590923LL, + 206436460129419264LL, + 29710560942LL, 849126597578981376LL, 30329530962LL, + 491816735028543488LL, + 30948500982LL, 134506872478105600LL, 31567471001LL, + 777197009927667712LL, + 32186441021LL, 419887147377229824LL, 32805411041LL, + 62577284826791936LL, + 33424381060LL, 705267422276354048LL, 34043351080LL, + 347957559725916160LL, + 34662321099LL, 990647697175478272LL, 35281291119LL, + 633337834625040384LL, + 35900261139LL, 276027972074602496LL, 36519231158LL, + 918718109524164608LL, + 37138201178LL, 561408246973726720LL, 37757171198LL, + 204098384423288832LL, + 38376141217LL, 846788521872850944LL, 38995111237LL, + 489478659322413056LL, + }, + + { + 0LL, 0LL, 39614081257LL, 132168796771975168LL, + 79228162514LL, 264337593543950336LL, 118842243771LL, + 396506390315925504LL, + 158456325028LL, 528675187087900672LL, 198070406285LL, + 660843983859875840LL, + 237684487542LL, 793012780631851008LL, 277298568799LL, + 925181577403826176LL, + 316912650057LL, 57350374175801344LL, 356526731314LL, + 189519170947776512LL, + 396140812571LL, 321687967719751680LL, 435754893828LL, + 453856764491726848LL, + 475368975085LL, 586025561263702016LL, 514983056342LL, + 718194358035677184LL, + 554597137599LL, 850363154807652352LL, 594211218856LL, + 982531951579627520LL, + 633825300114LL, 114700748351602688LL, 673439381371LL, + 246869545123577856LL, + 713053462628LL, 379038341895553024LL, 752667543885LL, + 511207138667528192LL, + 792281625142LL, 643375935439503360LL, 831895706399LL, + 775544732211478528LL, + 871509787656LL, 907713528983453696LL, 911123868914LL, + 39882325755428864LL, + 950737950171LL, 172051122527404032LL, 990352031428LL, + 304219919299379200LL, + 1029966112685LL, 436388716071354368LL, 1069580193942LL, + 568557512843329536LL, + 1109194275199LL, 700726309615304704LL, 1148808356456LL, + 832895106387279872LL, + 1188422437713LL, 965063903159255040LL, 1228036518971LL, + 97232699931230208LL, + 1267650600228LL, 229401496703205376LL, 1307264681485LL, + 361570293475180544LL, + 1346878762742LL, 493739090247155712LL, 1386492843999LL, + 625907887019130880LL, + 1426106925256LL, 758076683791106048LL, 1465721006513LL, + 890245480563081216LL, + 1505335087771LL, 22414277335056384LL, 1544949169028LL, + 154583074107031552LL, + 1584563250285LL, 286751870879006720LL, 1624177331542LL, + 418920667650981888LL, + 1663791412799LL, 551089464422957056LL, 1703405494056LL, + 683258261194932224LL, + 1743019575313LL, 815427057966907392LL, 1782633656570LL, + 947595854738882560LL, + 1822247737828LL, 79764651510857728LL, 1861861819085LL, + 211933448282832896LL, + 1901475900342LL, 344102245054808064LL, 1941089981599LL, + 476271041826783232LL, + 1980704062856LL, 608439838598758400LL, 2020318144113LL, + 740608635370733568LL, + 2059932225370LL, 872777432142708736LL, 2099546306628LL, + 4946228914683904LL, + 2139160387885LL, 137115025686659072LL, 2178774469142LL, + 269283822458634240LL, + 2218388550399LL, 401452619230609408LL, 2258002631656LL, + 533621416002584576LL, + 2297616712913LL, 665790212774559744LL, 2337230794170LL, + 797959009546534912LL, + 2376844875427LL, 930127806318510080LL, 2416458956685LL, + 62296603090485248LL, + 2456073037942LL, 194465399862460416LL, 2495687119199LL, + 326634196634435584LL, + }, + + { + 0LL, 0LL, 2535301200456LL, 458802993406410752LL, + 5070602400912LL, 917605986812821504LL, 7605903601369LL, + 376408980219232256LL, + 10141204801825LL, 835211973625643008LL, 12676506002282LL, + 294014967032053760LL, + 15211807202738LL, 752817960438464512LL, 17747108403195LL, + 211620953844875264LL, + 20282409603651LL, 670423947251286016LL, 22817710804108LL, + 129226940657696768LL, + 25353012004564LL, 588029934064107520LL, 27888313205021LL, + 46832927470518272LL, + 30423614405477LL, 505635920876929024LL, 32958915605933LL, + 964438914283339776LL, + 35494216806390LL, 423241907689750528LL, 38029518006846LL, + 882044901096161280LL, + 40564819207303LL, 340847894502572032LL, 43100120407759LL, + 799650887908982784LL, + 45635421608216LL, 258453881315393536LL, 48170722808672LL, + 717256874721804288LL, + 50706024009129LL, 176059868128215040LL, 53241325209585LL, + 634862861534625792LL, + 55776626410042LL, 93665854941036544LL, 58311927610498LL, + 552468848347447296LL, + 60847228810955LL, 11271841753858048LL, 63382530011411LL, + 470074835160268800LL, + 65917831211867LL, 928877828566679552LL, 68453132412324LL, + 387680821973090304LL, + 70988433612780LL, 846483815379501056LL, 73523734813237LL, + 305286808785911808LL, + 76059036013693LL, 764089802192322560LL, 78594337214150LL, + 222892795598733312LL, + 81129638414606LL, 681695789005144064LL, 83664939615063LL, + 140498782411554816LL, + 86200240815519LL, 599301775817965568LL, 88735542015976LL, + 58104769224376320LL, + 91270843216432LL, 516907762630787072LL, 93806144416888LL, + 975710756037197824LL, + 96341445617345LL, 434513749443608576LL, 98876746817801LL, + 893316742850019328LL, + 101412048018258LL, 352119736256430080LL, 103947349218714LL, + 810922729662840832LL, + 106482650419171LL, 269725723069251584LL, 109017951619627LL, + 728528716475662336LL, + 111553252820084LL, 187331709882073088LL, 114088554020540LL, + 646134703288483840LL, + 116623855220997LL, 104937696694894592LL, 119159156421453LL, + 563740690101305344LL, + 121694457621910LL, 22543683507716096LL, 124229758822366LL, + 481346676914126848LL, + 126765060022822LL, 940149670320537600LL, 129300361223279LL, + 398952663726948352LL, + 131835662423735LL, 857755657133359104LL, 134370963624192LL, + 316558650539769856LL, + 136906264824648LL, 775361643946180608LL, 139441566025105LL, + 234164637352591360LL, + 141976867225561LL, 692967630759002112LL, 144512168426018LL, + 151770624165412864LL, + 147047469626474LL, 610573617571823616LL, 149582770826931LL, + 69376610978234368LL, + 152118072027387LL, 528179604384645120LL, 154653373227843LL, + 986982597791055872LL, + 157188674428300LL, 445785591197466624LL, 159723975628756LL, + 904588584603877376LL, + }, + + { + 0LL, 0LL, 162259276829213LL, 363391578010288128LL, + 324518553658426LL, 726783156020576256LL, 486777830487640LL, + 90174734030864384LL, + 649037107316853LL, 453566312041152512LL, 811296384146066LL, + 816957890051440640LL, + 973555660975280LL, 180349468061728768LL, 1135814937804493LL, + 543741046072016896LL, + 1298074214633706LL, 907132624082305024LL, 1460333491462920LL, + 270524202092593152LL, + 1622592768292133LL, 633915780102881280LL, 1784852045121346LL, + 997307358113169408LL, + 1947111321950560LL, 360698936123457536LL, 2109370598779773LL, + 724090514133745664LL, + 2271629875608987LL, 87482092144033792LL, 2433889152438200LL, + 450873670154321920LL, + 2596148429267413LL, 814265248164610048LL, 2758407706096627LL, + 177656826174898176LL, + 2920666982925840LL, 541048404185186304LL, 3082926259755053LL, + 904439982195474432LL, + 3245185536584267LL, 267831560205762560LL, 3407444813413480LL, + 631223138216050688LL, + 3569704090242693LL, 994614716226338816LL, 3731963367071907LL, + 358006294236626944LL, + 3894222643901120LL, 721397872246915072LL, 4056481920730334LL, + 84789450257203200LL, + 4218741197559547LL, 448181028267491328LL, 4381000474388760LL, + 811572606277779456LL, + 4543259751217974LL, 174964184288067584LL, 4705519028047187LL, + 538355762298355712LL, + 4867778304876400LL, 901747340308643840LL, 5030037581705614LL, + 265138918318931968LL, + 5192296858534827LL, 628530496329220096LL, 5354556135364040LL, + 991922074339508224LL, + 5516815412193254LL, 355313652349796352LL, 5679074689022467LL, + 718705230360084480LL, + 5841333965851681LL, 82096808370372608LL, 6003593242680894LL, + 445488386380660736LL, + 6165852519510107LL, 808879964390948864LL, 6328111796339321LL, + 172271542401236992LL, + 6490371073168534LL, 535663120411525120LL, 6652630349997747LL, + 899054698421813248LL, + 6814889626826961LL, 262446276432101376LL, 6977148903656174LL, + 625837854442389504LL, + 7139408180485387LL, 989229432452677632LL, 7301667457314601LL, + 352621010462965760LL, + 7463926734143814LL, 716012588473253888LL, 7626186010973028LL, + 79404166483542016LL, + 7788445287802241LL, 442795744493830144LL, 7950704564631454LL, + 806187322504118272LL, + 8112963841460668LL, 169578900514406400LL, 8275223118289881LL, + 532970478524694528LL, + 8437482395119094LL, 896362056534982656LL, 8599741671948308LL, + 259753634545270784LL, + 8762000948777521LL, 623145212555558912LL, 8924260225606734LL, + 986536790565847040LL, + 9086519502435948LL, 349928368576135168LL, 9248778779265161LL, + 713319946586423296LL, + 9411038056094375LL, 76711524596711424LL, 9573297332923588LL, + 440103102606999552LL, + 9735556609752801LL, 803494680617287680LL, 9897815886582015LL, + 166886258627575808LL, + 10060075163411228LL, 530277836637863936LL, 10222334440240441LL, + 893669414648152064LL} +}; diff --git a/reftest/bid64_add.c b/reftest/bid64_add.c new file mode 100644 index 0000000..7010214 --- /dev/null +++ b/reftest/bid64_add.c @@ -0,0 +1,583 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +/***************************************************************************** + * BID64 add + ***************************************************************************** + * + * Algorithm description: + * + * if(exponent_a < exponent_b) + * switch a, b + * diff_expon = exponent_a - exponent_b + * if(diff_expon > 16) + * return normalize(a) + * if(coefficient_a*10^diff_expon guaranteed below 2^62) + * S = sign_a*coefficient_a*10^diff_expon + sign_b*coefficient_b + * if(|S|<10^16) + * return get_BID64(sign(S),exponent_b,|S|) + * else + * determine number of extra digits in S (1, 2, or 3) + * return rounded result + * else // large exponent difference + * if(number_digits(coefficient_a*10^diff_expon) +/- 10^16) + * guaranteed the same as + * number_digits(coefficient_a*10^diff_expon) ) + * S = normalize(coefficient_a + (sign_a^sign_b)*10^(16-diff_expon)) + * corr = 10^16 + (sign_a^sign_b)*coefficient_b + * corr*10^exponent_b is rounded so it aligns with S*10^exponent_S + * return get_BID64(sign_a,exponent(S),S+rounded(corr)) + * else + * add sign_a*coefficient_a*10^diff_expon, sign_b*coefficient_b + * in 128-bit integer arithmetic, then round to 16 decimal digits + * + * + ****************************************************************************/ + +#define BID_FUNCTION_SETS_BINARY_FLAGS + +#include + +#include "bid_internal.h" + +#if DECIMAL_CALL_BY_REFERENCE +void bid64_add(BID_UINT64* pres, BID_UINT64* px, + BID_UINT64* + py _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); +#else +BID_UINT64 bid64_add(BID_UINT64 x, + BID_UINT64 y _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); +#endif + +#if DECIMAL_CALL_BY_REFERENCE + +void bid64_sub(BID_UINT64* pres, BID_UINT64* px, + BID_UINT64* + py _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM) { + BID_UINT64 y = *py; +#if !DECIMAL_GLOBAL_ROUNDING + _IDEC_round rnd_mode = *prnd_mode; +#endif + // check if y is not NaN + if (((y & NAN_MASK64) != NAN_MASK64)) + y ^= 0x8000000000000000ull; + bid64_add(pres, px, + &y _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +} +#else +DFP_WRAPFN_DFP_DFP(64, bid64_sub, 64, 64) +BID_UINT64 +bid64_sub(BID_UINT64 x, + BID_UINT64 y _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { + // check if y is not NaN + if (((y & NAN_MASK64) != NAN_MASK64)) + y ^= 0x8000000000000000ull; + + return bid64_add(x, + y _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG + _EXC_INFO_ARG); +} +#endif + +BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2(BID_UINT64, bid64_add, BID_UINT64, x, BID_UINT64, y) + +BID_UINT128 CA, CT, CT_new; +BID_UINT64 sign_x, sign_y, coefficient_x, coefficient_y, C64_new; +BID_UINT64 valid_x, valid_y; +BID_UINT64 res; +BID_UINT64 sign_a, sign_b, coefficient_a, coefficient_b, sign_s, sign_ab, + rem_a; +BID_UINT64 saved_ca, saved_cb, C0_64, C64, remainder_h, T1, carry, tmp; +int_double tempx; +int exponent_x, exponent_y, exponent_a, exponent_b, diff_dec_expon; +int bin_expon_ca, extra_digits, amount, scale_k, scale_ca; +unsigned rmode, status; + +BID_OPT_SAVE_BINARY_FLAGS() + +valid_x = unpack_BID64(&sign_x, &exponent_x, &coefficient_x, x); +valid_y = unpack_BID64(&sign_y, &exponent_y, &coefficient_y, y); + +// unpack arguments, check for NaN or Infinity +if (!valid_x) { + // x is Inf. or NaN + + // test if x is NaN + if ((x & NAN_MASK64) == NAN_MASK64) { +#ifdef BID_SET_STATUS_FLAGS + if (((x & SNAN_MASK64) == SNAN_MASK64) // sNaN + || ((y & SNAN_MASK64) == SNAN_MASK64)) { + __set_status_flags(pfpsf, BID_INVALID_EXCEPTION); + } +#endif + res = coefficient_x & QUIET_MASK64; + BID_RETURN(res); + } + // x is Infinity? + if ((x & INFINITY_MASK64) == INFINITY_MASK64) { + // check if y is Inf + if (((y & NAN_MASK64) == INFINITY_MASK64)) { + if (sign_x == (y & 0x8000000000000000ull)) { + res = coefficient_x; + BID_RETURN(res); + } + // return NaN + { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags(pfpsf, BID_INVALID_EXCEPTION); +#endif + res = NAN_MASK64; + BID_RETURN(res); + } + } + // check if y is NaN + if (((y & NAN_MASK64) == NAN_MASK64)) { + res = coefficient_y & QUIET_MASK64; +#ifdef BID_SET_STATUS_FLAGS + if (((y & SNAN_MASK64) == SNAN_MASK64)) { + __set_status_flags(pfpsf, BID_INVALID_EXCEPTION); + } +#endif + BID_RETURN(res); + } + // otherwise return +/-Inf + { + res = coefficient_x; + BID_RETURN(res); + } + } + // x is 0 + { + if (((y & INFINITY_MASK64) != INFINITY_MASK64) && coefficient_y) { + if (exponent_y <= exponent_x) { + res = y; + BID_RETURN(res); + } + } + } +} +if (!valid_y) { + // y is Inf. or NaN? + if (((y & INFINITY_MASK64) == INFINITY_MASK64)) { +#ifdef BID_SET_STATUS_FLAGS + if ((y & SNAN_MASK64) == SNAN_MASK64) { // sNaN + __set_status_flags(pfpsf, BID_INVALID_EXCEPTION); + } +#endif + res = coefficient_y & QUIET_MASK64; + BID_RETURN(res); + } + // y is 0 + if (!coefficient_x) { // x==0 + if (exponent_x <= exponent_y) { + res = ((BID_UINT64)exponent_x) << 53; + } else { + res = ((BID_UINT64)exponent_y) << 53; + } + if (sign_x == sign_y) { + res |= sign_x; + } +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rnd_mode == BID_ROUNDING_DOWN && sign_x != sign_y) { + res |= 0x8000000000000000ull; + } +#endif +#endif + BID_RETURN(res); + } else if (exponent_y >= exponent_x) { + res = x; + BID_RETURN(res); + } +} +// sort arguments by exponent +if (exponent_x < exponent_y) { + sign_a = sign_y; + exponent_a = exponent_y; + coefficient_a = coefficient_y; + sign_b = sign_x; + exponent_b = exponent_x; + coefficient_b = coefficient_x; +} else { + sign_a = sign_x; + exponent_a = exponent_x; + coefficient_a = coefficient_x; + sign_b = sign_y; + exponent_b = exponent_y; + coefficient_b = coefficient_y; +} + +// exponent difference +diff_dec_expon = exponent_a - exponent_b; + +/* get binary coefficients of x and y */ + +//--- get number of bits in the coefficients of x and y --- + +// version 2 (original) +tempx.d = (double)coefficient_a; +bin_expon_ca = ((tempx.i & MASK_BINARY_EXPONENT) >> 52) - 0x3ff; + +if (diff_dec_expon > MAX_FORMAT_DIGITS) { + // normalize a to a 16-digit coefficient + + scale_ca = bid_estimate_decimal_digits[bin_expon_ca]; + if (coefficient_a >= bid_power10_table_128[scale_ca].w[0]) + scale_ca++; + + scale_k = 16 - scale_ca; + + coefficient_a *= bid_power10_table_128[scale_k].w[0]; + + diff_dec_expon -= scale_k; + exponent_a -= scale_k; + + /* get binary coefficients of x and y */ + + //--- get number of bits in the coefficients of x and y --- + tempx.d = (double)coefficient_a; + bin_expon_ca = ((tempx.i & MASK_BINARY_EXPONENT) >> 52) - 0x3ff; + + if (diff_dec_expon > MAX_FORMAT_DIGITS) { +#ifdef BID_SET_STATUS_FLAGS + if (coefficient_b) { + __set_status_flags(pfpsf, BID_INEXACT_EXCEPTION); + } +#endif + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (((rnd_mode) & 3) && coefficient_b) // not BID_ROUNDING_TO_NEAREST + { + switch (rnd_mode) { + case BID_ROUNDING_DOWN: + if (sign_b) { + coefficient_a -= ((((BID_SINT64)sign_a) >> 63) | 1); + if (coefficient_a < 1000000000000000ull) { + exponent_a--; + coefficient_a = 9999999999999999ull; + } else if (coefficient_a >= 10000000000000000ull) { + exponent_a++; + coefficient_a = 1000000000000000ull; + } + } + break; + case BID_ROUNDING_UP: + if (!sign_b) { + coefficient_a += ((((BID_SINT64)sign_a) >> 63) | 1); + if (coefficient_a < 1000000000000000ull) { + exponent_a--; + coefficient_a = 9999999999999999ull; + } else if (coefficient_a >= 10000000000000000ull) { + exponent_a++; + coefficient_a = 1000000000000000ull; + } + } + break; + default: // RZ + if (sign_a != sign_b) { + coefficient_a--; + if (coefficient_a < 1000000000000000ull) { + exponent_a--; + coefficient_a = 9999999999999999ull; + } + } + break; + } + } else +#endif +#endif + // check special case here + if ((coefficient_a == 1000000000000000ull) && (diff_dec_expon == MAX_FORMAT_DIGITS + 1) && (sign_a ^ sign_b) && (coefficient_b > 5000000000000000ull)) { + coefficient_a = 9999999999999999ull; + exponent_a--; + } + + res = + fast_get_BID64_check_OF(sign_a, exponent_a, coefficient_a, + rnd_mode, pfpsf); + BID_RETURN(res); + } +} +// test whether coefficient_a*10^(exponent_a-exponent_b) may exceed 2^62 +if (bin_expon_ca + bid_estimate_bin_expon[diff_dec_expon] < 60) { + // coefficient_a*10^(exponent_a-exponent_b)<2^63 + + // multiply by 10^(exponent_a-exponent_b) + coefficient_a *= bid_power10_table_128[diff_dec_expon].w[0]; + + // sign mask + sign_b = ((BID_SINT64)sign_b) >> 63; + // apply sign to coeff. of b + coefficient_b = (coefficient_b + sign_b) ^ sign_b; + + // apply sign to coefficient a + sign_a = ((BID_SINT64)sign_a) >> 63; + coefficient_a = (coefficient_a + sign_a) ^ sign_a; + + coefficient_a += coefficient_b; + // get sign + sign_s = ((BID_SINT64)coefficient_a) >> 63; + coefficient_a = (coefficient_a + sign_s) ^ sign_s; + sign_s &= 0x8000000000000000ull; + + // coefficient_a < 10^16 ? + if (coefficient_a < bid_power10_table_128[MAX_FORMAT_DIGITS].w[0]) { +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rnd_mode == BID_ROUNDING_DOWN && (!coefficient_a) && sign_a != sign_b) + sign_s = 0x8000000000000000ull; +#endif +#endif + res = very_fast_get_BID64(sign_s, exponent_b, coefficient_a); + BID_RETURN(res); + } + // otherwise rounding is necessary + + // already know coefficient_a<10^19 + // coefficient_a < 10^17 ? + if (coefficient_a < bid_power10_table_128[17].w[0]) + extra_digits = 1; + else if (coefficient_a < bid_power10_table_128[18].w[0]) + extra_digits = 2; + else + extra_digits = 3; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + rmode = rnd_mode; + if (sign_s && (unsigned)(rmode - 1) < 2) + rmode = 3 - rmode; +#else + rmode = 0; +#endif +#else + rmode = 0; +#endif + coefficient_a += bid_round_const_table[rmode][extra_digits]; + + // get P*(2^M[extra_digits])/10^extra_digits + __mul_64x64_to_128(CT, coefficient_a, + bid_reciprocals10_64[extra_digits]); + + // now get P/10^extra_digits: shift C64 right by M[extra_digits]-128 + amount = bid_short_recip_scale[extra_digits]; + C64 = CT.w[1] >> amount; + +} else { + // coefficient_a*10^(exponent_a-exponent_b) is large + sign_s = sign_a; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + rmode = rnd_mode; + if (sign_s && (unsigned)(rmode - 1) < 2) + rmode = 3 - rmode; +#else + rmode = 0; +#endif +#else + rmode = 0; +#endif + + // check whether we can take faster path + scale_ca = bid_estimate_decimal_digits[bin_expon_ca]; + + sign_ab = sign_a ^ sign_b; + sign_ab = ((BID_SINT64)sign_ab) >> 63; + + // T1 = 10^(16-diff_dec_expon) + T1 = bid_power10_table_128[16 - diff_dec_expon].w[0]; + + // get number of digits in coefficient_a + if (coefficient_a >= bid_power10_table_128[scale_ca].w[0]) { + scale_ca++; + } + + scale_k = 16 - scale_ca; + + // addition + saved_ca = coefficient_a - T1; + coefficient_a = + (BID_SINT64)saved_ca * (BID_SINT64)bid_power10_table_128[scale_k].w[0]; + extra_digits = diff_dec_expon - scale_k; + + // apply sign + saved_cb = (coefficient_b + sign_ab) ^ sign_ab; + // add 10^16 and rounding constant + coefficient_b = + saved_cb + 10000000000000000ull + + bid_round_const_table[rmode][extra_digits]; + + // get P*(2^M[extra_digits])/10^extra_digits + __mul_64x64_to_128(CT, coefficient_b, + bid_reciprocals10_64[extra_digits]); + + // now get P/10^extra_digits: shift C64 right by M[extra_digits]-128 + amount = bid_short_recip_scale[extra_digits]; + C0_64 = CT.w[1] >> amount; + + // result coefficient + C64 = C0_64 + coefficient_a; + // filter out difficult (corner) cases + // this test ensures the number of digits in coefficient_a does not change + // after adding (the appropriately scaled and rounded) coefficient_b + if ((BID_UINT64)(C64 - 1000000000000000ull - 1) > + 9000000000000000ull - 2) { + if (C64 >= 10000000000000000ull) { + // result has more than 16 digits + if (!scale_k) { + // must divide coeff_a by 10 + saved_ca = saved_ca + T1; + __mul_64x64_to_128(CA, saved_ca, 0x3333333333333334ull); + // reciprocals10_64[1]); + coefficient_a = CA.w[1] >> 1; + rem_a = + saved_ca - (coefficient_a << 3) - (coefficient_a << 1); + coefficient_a = coefficient_a - T1; + + saved_cb += rem_a * bid_power10_table_128[diff_dec_expon].w[0]; + } else + coefficient_a = + (BID_SINT64)(saved_ca - T1 - + (T1 << 3)) * + (BID_SINT64)bid_power10_table_128[scale_k - + 1] + .w[0]; + + extra_digits++; + coefficient_b = + saved_cb + 100000000000000000ull + + bid_round_const_table[rmode][extra_digits]; + + // get P*(2^M[extra_digits])/10^extra_digits + __mul_64x64_to_128(CT, coefficient_b, + bid_reciprocals10_64[extra_digits]); + + // now get P/10^extra_digits: shift C64 right by M[extra_digits]-128 + amount = bid_short_recip_scale[extra_digits]; + C0_64 = CT.w[1] >> amount; + + // result coefficient + C64 = C0_64 + coefficient_a; + } else if (C64 <= 1000000000000000ull) { + // less than 16 digits in result + coefficient_a = + (BID_SINT64)saved_ca * (BID_SINT64)bid_power10_table_128[scale_k + + 1] + .w[0]; + // extra_digits --; + exponent_b--; + coefficient_b = + (saved_cb << 3) + (saved_cb << 1) + 100000000000000000ull + + bid_round_const_table[rmode][extra_digits]; + + // get P*(2^M[extra_digits])/10^extra_digits + __mul_64x64_to_128(CT_new, coefficient_b, + bid_reciprocals10_64[extra_digits]); + + // now get P/10^extra_digits: shift C64 right by M[extra_digits]-128 + amount = bid_short_recip_scale[extra_digits]; + C0_64 = CT_new.w[1] >> amount; + + // result coefficient + C64_new = C0_64 + coefficient_a; + if (C64_new < 10000000000000000ull) { + C64 = C64_new; +#ifdef BID_SET_STATUS_FLAGS + CT = CT_new; +#endif + } else + exponent_b++; + } + } +} + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST +if (rmode == 0) // BID_ROUNDING_TO_NEAREST +#endif + if (C64 & 1) { + // check whether fractional part of initial_P/10^extra_digits is + // exactly .5 + // this is the same as fractional part of + // (initial_P + 0.5*10^extra_digits)/10^extra_digits is exactly zero + + // get remainder + remainder_h = CT.w[1] << (64 - amount); + + // test whether fractional part is 0 + if (!remainder_h && (CT.w[0] < bid_reciprocals10_64[extra_digits])) { + C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS +status = BID_INEXACT_EXCEPTION; + +// get remainder +remainder_h = CT.w[1] << (64 - amount); + +switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if ((remainder_h == 0x8000000000000000ull) && (CT.w[0] < bid_reciprocals10_64[extra_digits])) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h && (CT.w[0] < bid_reciprocals10_64[extra_digits])) + status = BID_EXACT_STATUS; + // if(!C64 && rmode==BID_ROUNDING_DOWN) sign_s=sign_y; + break; + default: + // round up + __add_carry_out(tmp, carry, CT.w[0], + bid_reciprocals10_64[extra_digits]); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64)1) << amount)) + status = BID_EXACT_STATUS; + break; +} +__set_status_flags(pfpsf, status); + +#endif + +res = + fast_get_BID64_check_OF(sign_s, exponent_b + extra_digits, C64, + rnd_mode, pfpsf); +BID_RETURN(res); +} diff --git a/reftest/bid64_mul.c b/reftest/bid64_mul.c new file mode 100644 index 0000000..7fe8a0c --- /dev/null +++ b/reftest/bid64_mul.c @@ -0,0 +1,366 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +/***************************************************************************** + * BID64 multiply + ***************************************************************************** + * + * Algorithm description: + * + * if(number_digits(coefficient_x)+number_digits(coefficient_y) guaranteed + * below 16) + * return get_BID64(sign_x^sign_y, exponent_x + exponent_y - dec_bias, + * coefficient_x*coefficient_y) + * else + * get long product: coefficient_x*coefficient_y + * determine number of digits to round off (extra_digits) + * rounding is performed as a 128x128-bit multiplication by + * 2^M[extra_digits]/10^extra_digits, followed by a shift + * M[extra_digits] is sufficiently large for required accuracy + * + ****************************************************************************/ + +#define BID_FUNCTION_SETS_BINARY_FLAGS +#include "bid_internal.h" + +BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2(BID_UINT64, bid64_mul, BID_UINT64, x, BID_UINT64, y) + BID_UINT128 P, C128, Q_high, Q_low, Stemp; +#if DECIMAL_TINY_DETECTION_AFTER_ROUNDING + BID_UINT128 PU; +#endif + BID_UINT64 sign_x, sign_y, coefficient_x, coefficient_y; + BID_UINT64 C64, remainder_h, carry, CY, res; + BID_UINT64 valid_x, valid_y; + int_double tempx, tempy; + int extra_digits, exponent_x, exponent_y, bin_expon_cx, bin_expon_cy, + bin_expon_product; + int rmode, digits_p, bp, amount, amount2, final_exponent, round_up; + unsigned status, uf_status; + + BID_OPT_SAVE_BINARY_FLAGS() + + valid_x = unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x); + valid_y = unpack_BID64 (&sign_y, &exponent_y, &coefficient_y, y); + + // unpack arguments, check for NaN or Infinity + if (!valid_x) { + +#ifdef BID_SET_STATUS_FLAGS + if ((y & SNAN_MASK64) == SNAN_MASK64) // y is sNaN + __set_status_flags (pfpsf, BID_INVALID_EXCEPTION); +#endif + // x is Inf. or NaN + + // test if x is NaN + if ((x & NAN_MASK64) == NAN_MASK64) { +#ifdef BID_SET_STATUS_FLAGS + if ((x & SNAN_MASK64) == SNAN_MASK64) // sNaN + __set_status_flags (pfpsf, BID_INVALID_EXCEPTION); +#endif + BID_RETURN (coefficient_x & QUIET_MASK64); + } + // x is Infinity? + if ((x & INFINITY_MASK64) == INFINITY_MASK64) { + // check if y is 0 + if (((y & INFINITY_MASK64) != INFINITY_MASK64) + && !coefficient_y) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (pfpsf, BID_INVALID_EXCEPTION); +#endif + // y==0 , return NaN + BID_RETURN (NAN_MASK64); + } + // check if y is NaN + if ((y & NAN_MASK64) == NAN_MASK64) + // y==NaN , return NaN + BID_RETURN (coefficient_y & QUIET_MASK64); + // otherwise return +/-Inf + BID_RETURN (((x ^ y) & 0x8000000000000000ull) | INFINITY_MASK64); + } + // x is 0 + if (((y & INFINITY_MASK64) != INFINITY_MASK64)) { + if ((y & SPECIAL_ENCODING_MASK64) == SPECIAL_ENCODING_MASK64) + exponent_y = ((BID_UINT32) (y >> 51)) & 0x3ff; + else + exponent_y = ((BID_UINT32) (y >> 53)) & 0x3ff; + sign_y = y & 0x8000000000000000ull; + + exponent_x += exponent_y - DECIMAL_EXPONENT_BIAS; + if (exponent_x > DECIMAL_MAX_EXPON_64) + exponent_x = DECIMAL_MAX_EXPON_64; + else if (exponent_x < 0) + exponent_x = 0; + BID_RETURN ((sign_x ^ sign_y) | (((BID_UINT64) exponent_x) << 53)); + } + } + if (!valid_y) { + // y is Inf. or NaN + + // test if y is NaN + if ((y & NAN_MASK64) == NAN_MASK64) { +#ifdef BID_SET_STATUS_FLAGS + if ((y & SNAN_MASK64) == SNAN_MASK64) // sNaN + __set_status_flags (pfpsf, BID_INVALID_EXCEPTION); +#endif + BID_RETURN (coefficient_y & QUIET_MASK64); + } + // y is Infinity? + if ((y & INFINITY_MASK64) == INFINITY_MASK64) { + // check if x is 0 + if (!coefficient_x) { + __set_status_flags (pfpsf, BID_INVALID_EXCEPTION); + // x==0, return NaN + BID_RETURN (NAN_MASK64); + } + // otherwise return +/-Inf + BID_RETURN (((x ^ y) & 0x8000000000000000ull) | INFINITY_MASK64); + } + // y is 0 + exponent_x += exponent_y - DECIMAL_EXPONENT_BIAS; + if (exponent_x > DECIMAL_MAX_EXPON_64) + exponent_x = DECIMAL_MAX_EXPON_64; + else if (exponent_x < 0) + exponent_x = 0; + BID_RETURN ((sign_x ^ sign_y) | (((BID_UINT64) exponent_x) << 53)); + } + //--- get number of bits in the coefficients of x and y --- + // version 2 (original) + tempx.d = (double) coefficient_x; + bin_expon_cx = ((tempx.i & MASK_BINARY_EXPONENT) >> 52); + tempy.d = (double) coefficient_y; + bin_expon_cy = ((tempy.i & MASK_BINARY_EXPONENT) >> 52); + + // magnitude estimate for coefficient_x*coefficient_y is + // 2^(unbiased_bin_expon_cx + unbiased_bin_expon_cx) + bin_expon_product = bin_expon_cx + bin_expon_cy; + + // check if coefficient_x*coefficient_y<2^(10*k+3) + // equivalent to unbiased_bin_expon_cx + unbiased_bin_expon_cx < 10*k+1 + if (bin_expon_product < UPPER_EXPON_LIMIT + 2 * BINARY_EXPONENT_BIAS) { + // easy multiply + C64 = coefficient_x * coefficient_y; + + res = + get_BID64_small_mantissa (sign_x ^ sign_y, + exponent_x + exponent_y - + DECIMAL_EXPONENT_BIAS, C64, rnd_mode, + pfpsf); + BID_RETURN (res); + } else { + uf_status = 0; + // get 128-bit product: coefficient_x*coefficient_y + __mul_64x64_to_128 (P, coefficient_x, coefficient_y); + + // tighten binary range of P: leading bit is 2^bp + // unbiased_bin_expon_product <= bp <= unbiased_bin_expon_product+1 + bin_expon_product -= 2 * BINARY_EXPONENT_BIAS; + + __tight_bin_range_128 (bp, P, bin_expon_product); + + // get number of decimal digits in the product + digits_p = bid_estimate_decimal_digits[bp]; + if (!(__unsigned_compare_gt_128 (bid_power10_table_128[digits_p], P))) + digits_p++; // if bid_power10_table_128[digits_p] <= P + + // determine number of decimal digits to be rounded out + extra_digits = digits_p - MAX_FORMAT_DIGITS; + final_exponent = + exponent_x + exponent_y + extra_digits - DECIMAL_EXPONENT_BIAS; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + rmode = rnd_mode; + if (sign_x ^ sign_y && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#else + rmode = 0; +#endif +#else + rmode = 0; +#endif + + round_up = 0; + if (((unsigned) final_exponent) >= 3 * 256) { + if (final_exponent < 0) { + // underflow + if (final_exponent + 16 < 0) { + res = sign_x ^ sign_y; + __set_status_flags (pfpsf, + BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); + if (rmode == BID_ROUNDING_UP) + res |= 1; + BID_RETURN (res); + } + + uf_status = BID_UNDERFLOW_EXCEPTION; +#if DECIMAL_TINY_DETECTION_AFTER_ROUNDING + if (final_exponent == -1) { + __add_128_64 (PU, P, bid_round_const_table[rmode][extra_digits]); + if (__unsigned_compare_ge_128 + (PU, bid_power10_table_128[extra_digits + 16])) + uf_status = 0; + } +#endif + extra_digits -= final_exponent; + final_exponent = 0; + + if (extra_digits > 17) { + __mul_128x128_full (Q_high, Q_low, P, bid_reciprocals10_128[16]); + + amount = bid_recip_scale[16]; + __shr_128 (P, Q_high, amount); + + // get sticky bits + amount2 = 64 - amount; + remainder_h = 0; + remainder_h--; + remainder_h >>= amount2; + remainder_h = remainder_h & Q_high.w[0]; + + extra_digits -= 16; + if (remainder_h || (Q_low.w[1] > bid_reciprocals10_128[16].w[1] + || (Q_low.w[1] == + bid_reciprocals10_128[16].w[1] + && Q_low.w[0] >= + bid_reciprocals10_128[16].w[0]))) { + round_up = 1; + __set_status_flags (pfpsf, + BID_UNDERFLOW_EXCEPTION | + BID_INEXACT_EXCEPTION); + P.w[0] = (P.w[0] << 3) + (P.w[0] << 1); + P.w[0] |= 1; + extra_digits++; + } + } + } else { + res = + fast_get_BID64_check_OF (sign_x ^ sign_y, final_exponent, + 1000000000000000ull, rnd_mode, + pfpsf); + BID_RETURN (res); + } + } + + + if (extra_digits > 0) { + // will divide by 10^(digits_p - 16) + + // add a constant to P, depending on rounding mode + // 0.5*10^(digits_p - 16) for round-to-nearest + __add_128_64 (P, P, bid_round_const_table[rmode][extra_digits]); + + // get P*(2^M[extra_digits])/10^extra_digits + __mul_128x128_full (Q_high, Q_low, P, + bid_reciprocals10_128[extra_digits]); + + // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 + amount = bid_recip_scale[extra_digits]; + __shr_128 (C128, Q_high, amount); + + C64 = __low_64 (C128); + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == 0) //BID_ROUNDING_TO_NEAREST +#endif + if ((C64 & 1) && !round_up) { + // check whether fractional part of initial_P/10^extra_digits + // is exactly .5 + // this is the same as fractional part of + // (initial_P + 0.5*10^extra_digits)/10^extra_digits is exactly zero + + // get remainder + remainder_h = Q_high.w[0] << (64 - amount); + + // test whether fractional part is 0 + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) { + C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + status = BID_INEXACT_EXCEPTION | uf_status; + + // get remainder + remainder_h = Q_high.w[0] << (64 - amount); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (remainder_h == 0x8000000000000000ull + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp.w[0], CY, Q_low.w[0], + bid_reciprocals10_128[extra_digits].w[0]); + __add_carry_in_out (Stemp.w[1], carry, Q_low.w[1], + bid_reciprocals10_128[extra_digits].w[1], CY); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64) 1) << amount)) + status = BID_EXACT_STATUS; + } + + __set_status_flags (pfpsf, status); +#endif + + // convert to BID and return + res = + fast_get_BID64_check_OF (sign_x ^ sign_y, final_exponent, C64, + rnd_mode, pfpsf); + BID_RETURN (res); + } + // go to convert_format and exit + C64 = __low_64 (P); + res = + get_BID64 (sign_x ^ sign_y, + exponent_x + exponent_y - DECIMAL_EXPONENT_BIAS, C64, + rnd_mode, pfpsf); + BID_RETURN (res); + } +} diff --git a/reftest/bid64_string.c b/reftest/bid64_string.c new file mode 100644 index 0000000..17f9f43 --- /dev/null +++ b/reftest/bid64_string.c @@ -0,0 +1,538 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 +#include "bid_internal.h" +#include "bid128_2_str.h" +#include "bid128_2_str_macros.h" + +#define MAX_FORMAT_DIGITS 16 +#define DECIMAL_EXPONENT_BIAS 398 +#define MAX_DECIMAL_EXPONENT 767 + +#if DECIMAL_CALL_BY_REFERENCE + +void +bid64_to_string (char *ps, BID_UINT64 * px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { + BID_UINT64 x; +#else + +VOID_WRAPFN_OTHERTYPERES_DFP(bid64_to_string, char, 64) +void +bid64_to_string (char *ps, BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { +#endif +// the destination string (pointed to by ps) must be pre-allocated + BID_UINT64 sign_x, coefficient_x, D, ER10; + int istart, exponent_x, j, digits_x, bin_expon_cx; + int_float tempx; + BID_UINT32 MiDi[12], *ptr; + BID_UINT64 HI_18Dig, LO_18Dig, Tmp; + char *c_ptr_start, *c_ptr; + int midi_ind, k_lcv, len; + unsigned int save_fpsf; + +#if DECIMAL_CALL_BY_REFERENCE + x = *px; +#endif + + save_fpsf = *pfpsf; // place holder only + // unpack arguments, check for NaN or Infinity + if (!unpack_BID64 (&sign_x, &exponent_x, &coefficient_x, x)) { + // x is Inf. or NaN or 0 + + // Inf or NaN? + if ((x & 0x7800000000000000ull) == 0x7800000000000000ull) { + if ((x & 0x7c00000000000000ull) == 0x7c00000000000000ull) { + ps[0] = (sign_x) ? '-' : '+'; + ps[1] = 'S'; + j = ((x & MASK_SNAN) == MASK_SNAN)? 2: 1; + ps[j++] = 'N'; + ps[j++] = 'a'; + ps[j++] = 'N'; + ps[j++] = 0; + return; + } + // x is Inf + ps[0] = (sign_x) ? '-' : '+'; + ps[1] = 'I'; + ps[2] = 'n'; + ps[3] = 'f'; + ps[4] = 0; + return; + } + // 0 + istart = 1; + ps[0] = (sign_x)? '-': '+'; + + ps[istart++] = '0'; + ps[istart++] = 'E'; + + exponent_x -= 398; + if (exponent_x < 0) { + ps[istart++] = '-'; + exponent_x = -exponent_x; + } else + ps[istart++] = '+'; + + if (exponent_x) { + // get decimal digits in coefficient_x + tempx.d = (float) exponent_x; + bin_expon_cx = ((tempx.i >> 23) & 0xff) - 0x7f; + digits_x = bid_estimate_decimal_digits[bin_expon_cx]; + if ((BID_UINT64)exponent_x >= bid_power10_table_128[digits_x].w[0]) + digits_x++; + + j = istart + digits_x - 1; + istart = j + 1; + + // 2^32/10 + ER10 = 0x1999999a; + + while (exponent_x > 9) { + D = (BID_UINT64) exponent_x *ER10; + D >>= 32; + exponent_x = exponent_x - (D << 1) - (D << 3); + + ps[j--] = '0' + (char) exponent_x; + exponent_x = D; + } + ps[j] = '0' + (char) exponent_x; + } else { + ps[istart++] = '0'; + } + + ps[istart] = 0; + + return; + } + // convert expon, coeff to ASCII + exponent_x -= DECIMAL_EXPONENT_BIAS; + + ER10 = 0x1999999a; + + istart = 1; + ps[0] = (sign_x)? '-': '+'; + + // if zero or non-canonical, set coefficient to '0' + if ((coefficient_x > 9999999999999999ull) || // non-canonical + ((coefficient_x == 0)) // significand is zero + ) { + ps[istart++] = '0'; + } else { + /* **************************************************** + This takes a bid coefficient in C1.w[1],C1.w[0] + and put the converted character sequence at location + starting at &(str[k]). The function returns the number + of MiDi returned. Note that the character sequence + does not have leading zeros EXCEPT when the input is of + zero value. It will then output 1 character '0' + The algorithm essentailly tries first to get a sequence of + Millenial Digits "MiDi" and then uses table lookup to get the + character strings of these MiDis. + **************************************************** */ + /* Algorithm first decompose possibly 34 digits in hi and lo + 18 digits. (The high can have at most 16 digits). It then + uses macro that handle 18 digit portions. + The first step is to get hi and lo such that + 2^(64) C1.w[1] + C1.w[0] = hi * 10^18 + lo, 0 <= lo < 10^18. + We use a table lookup method to obtain the hi and lo 18 digits. + [C1.w[1],C1.w[0]] = c_8 2^(107) + c_7 2^(101) + ... + c_0 2^(59) + d + where 0 <= d < 2^59 and each c_j has 6 bits. Because d fits in + 18 digits, we set hi = 0, and lo = d to begin with. + We then retrieve from a table, for j = 0, 1, ..., 8 + that gives us A and B where c_j 2^(59+6j) = A * 10^18 + B. + hi += A ; lo += B; After each accumulation into lo, we normalize + immediately. So at the end, we have the decomposition as we need. */ + + Tmp = coefficient_x >> 59; + LO_18Dig = (coefficient_x << 5) >> 5; + HI_18Dig = 0; + k_lcv = 0; + + while (Tmp) { + midi_ind = (int) (Tmp & 0x000000000000003FLL); + midi_ind <<= 1; + Tmp >>= 6; + HI_18Dig += mod10_18_tbl[k_lcv][midi_ind++]; + LO_18Dig += mod10_18_tbl[k_lcv++][midi_ind]; + __L0_Normalize_10to18 (HI_18Dig, LO_18Dig); + } + + ptr = MiDi; + __L1_Split_MiDi_6_Lead (LO_18Dig, ptr); + len = ptr - MiDi; + c_ptr_start = &(ps[istart]); + c_ptr = c_ptr_start; + + /* now convert the MiDi into character strings */ + __L0_MiDi2Str_Lead (MiDi[0], c_ptr); + for (k_lcv = 1; k_lcv < len; k_lcv++) { + __L0_MiDi2Str (MiDi[k_lcv], c_ptr); + } + istart = istart + (c_ptr - c_ptr_start); + } + + ps[istart++] = 'E'; + + if (exponent_x < 0) { + ps[istart++] = '-'; + exponent_x = -exponent_x; + } else + ps[istart++] = '+'; + + if (exponent_x) { + // get decimal digits in coefficient_x + tempx.d = (float) exponent_x; + bin_expon_cx = ((tempx.i >> 23) & 0xff) - 0x7f; + digits_x = bid_estimate_decimal_digits[bin_expon_cx]; + if ((BID_UINT64)exponent_x >= bid_power10_table_128[digits_x].w[0]) + digits_x++; + + j = istart + digits_x - 1; + istart = j + 1; + + // 2^32/10 + ER10 = 0x1999999a; + + while (exponent_x > 9) { + D = (BID_UINT64) exponent_x *ER10; + D >>= 32; + exponent_x = exponent_x - (D << 1) - (D << 3); + + ps[j--] = '0' + (char) exponent_x; + exponent_x = D; + } + ps[j] = '0' + (char) exponent_x; + } else { + ps[istart++] = '0'; + } + + ps[istart] = 0; + + return; + +} + + +#if DECIMAL_CALL_BY_REFERENCE +void +bid64_from_string (BID_UINT64 * pres, char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { +#else +DFP_WRAPFN_OTHERTYPE(64, bid64_from_string, char*) +BID_UINT64 +bid64_from_string (char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { +#endif + BID_UINT64 sign_x, coefficient_x = 0, rounded = 0, res; + int expon_x = 0, sgn_expon, ndigits, add_expon = 0, midpoint = + 0, rounded_up = 0, dround = 0; + int dec_expon_scale = 0, right_radix_leading_zeros = 0, rdx_pt_enc = + 0; + char c; + unsigned int save_fpsf; + +#if DECIMAL_CALL_BY_REFERENCE +#if !DECIMAL_GLOBAL_ROUNDING + _IDEC_round rnd_mode = *prnd_mode; +#endif +#endif + + save_fpsf = *pfpsf; // place holder only + // eliminate leading whitespace + while (((*ps == ' ') || (*ps == '\t')) && (*ps)) + ps++; + + // get first non-whitespace character + c = *ps; + + // detect special cases (INF or NaN) + if (!c || (c != '.' && c != '-' && c != '+' && (c < '0' || c > '9'))) { + // Infinity? + if ((tolower_macro (ps[0]) == 'i' && tolower_macro (ps[1]) == 'n' && + tolower_macro (ps[2]) == 'f') && (!ps[3] || + (tolower_macro (ps[3]) == 'i' && + tolower_macro (ps[4]) == 'n' && tolower_macro (ps[5]) == 'i' && + tolower_macro (ps[6]) == 't' && tolower_macro (ps[7]) == 'y' && + !ps[8]))) { + res = 0x7800000000000000ull; + BID_RETURN (res); + } + // return sNaN + if (tolower_macro (ps[0]) == 's' && tolower_macro (ps[1]) == 'n' && + tolower_macro (ps[2]) == 'a' && tolower_macro (ps[3]) == 'n') { + // case insensitive check for snan + res = 0x7e00000000000000ull; + BID_RETURN (res); + } else { + // return qNaN + res = 0x7c00000000000000ull; + BID_RETURN (res); + } + } + // detect +INF or -INF + if ((tolower_macro (ps[1]) == 'i' && tolower_macro (ps[2]) == 'n' && + tolower_macro (ps[3]) == 'f') && (!ps[4] || + (tolower_macro (ps[4]) == 'i' && tolower_macro (ps[5]) == 'n' && + tolower_macro (ps[6]) == 'i' && tolower_macro (ps[7]) == 't' && + tolower_macro (ps[8]) == 'y' && !ps[9]))) { + if (c == '+') + res = 0x7800000000000000ull; + else if (c == '-') + res = 0xf800000000000000ull; + else + res = 0x7c00000000000000ull; + BID_RETURN (res); + } + // if +sNaN, +SNaN, -sNaN, or -SNaN + if (tolower_macro (ps[1]) == 's' && tolower_macro (ps[2]) == 'n' + && tolower_macro (ps[3]) == 'a' && tolower_macro (ps[4]) == 'n') { + if (c == '-') + res = 0xfe00000000000000ull; + else + res = 0x7e00000000000000ull; + BID_RETURN (res); + } + // determine sign + if (c == '-') + sign_x = 0x8000000000000000ull; + else + sign_x = 0; + + // get next character if leading +/- sign + if (c == '-' || c == '+') { + ps++; + c = *ps; + } + // if c isn't a decimal point or a decimal digit, return NaN + if (c != '.' && (c < '0' || c > '9')) { + // return NaN + res = 0x7c00000000000000ull | sign_x; + BID_RETURN (res); + } + + rdx_pt_enc = 0; + + // detect zero (and eliminate/ignore leading zeros) + if (*(ps) == '0' || *(ps) == '.') { + + if (*(ps) == '.') { + rdx_pt_enc = 1; + ps++; + } + // if all numbers are zeros (with possibly 1 radix point, the number is zero + // should catch cases such as: 000.0 + while (*ps == '0') { + ps++; + // for numbers such as 0.0000000000000000000000000000000000001001, + // we want to count the leading zeros + if (rdx_pt_enc) { + right_radix_leading_zeros++; + } + // if this character is a radix point, make sure we haven't already + // encountered one + if (*(ps) == '.') { + if (rdx_pt_enc == 0) { + rdx_pt_enc = 1; + // if this is the first radix point, and the next character is NULL, + // we have a zero + if (!*(ps + 1)) { + res = + ((BID_UINT64) (398 - right_radix_leading_zeros) << 53) | + sign_x; + BID_RETURN (res); + } + ps = ps + 1; + } else { + // if 2 radix points, return NaN + res = 0x7c00000000000000ull | sign_x; + BID_RETURN (res); + } + } else if (!*(ps)) { + //pres->w[1] = 0x3040000000000000ull | sign_x; + res = + ((BID_UINT64) (398 - right_radix_leading_zeros) << 53) | sign_x; + BID_RETURN (res); + } + } + } + + c = *ps; + + ndigits = 0; + while ((c >= '0' && c <= '9') || c == '.') { + if (c == '.') { + if (rdx_pt_enc) { + // return NaN + res = 0x7c00000000000000ull | sign_x; + BID_RETURN (res); + } + rdx_pt_enc = 1; + ps++; + c = *ps; + continue; + } + dec_expon_scale += rdx_pt_enc; + + ndigits++; + if (ndigits <= 16) { + coefficient_x = (coefficient_x << 1) + (coefficient_x << 3); + coefficient_x += (BID_UINT64) (c - '0'); + } else if (ndigits == 17) { + // coefficient rounding + switch(rnd_mode){ + case BID_ROUNDING_TO_NEAREST: + midpoint = (c == '5' && !(coefficient_x & 1)) ? 1 : 0; + // if coefficient is even and c is 5, prepare to round up if + // subsequent digit is nonzero + // if str[MAXDIG+1] > 5, we MUST round up + // if str[MAXDIG+1] == 5 and coefficient is ODD, ROUND UP! + if (c > '5' || (c == '5' && (coefficient_x & 1))) { + coefficient_x++; + rounded_up = 1; + break; + + case BID_ROUNDING_DOWN: + if(sign_x) { if(c>'0') {coefficient_x++; rounded_up=1;} else dround=1; } + break; + case BID_ROUNDING_UP: + if(!sign_x) { if(c>'0') {coefficient_x++; rounded_up=1;} else dround=1; } + break; + case BID_ROUNDING_TIES_AWAY: + if(c>='5') { coefficient_x++; rounded_up=1; } + break; + } + if (coefficient_x == 10000000000000000ull) { + coefficient_x = 1000000000000000ull; + add_expon = 1; + } + } + if (c > '0') + rounded = 1; + add_expon += 1; + } else { // ndigits > 17 + add_expon++; + if (midpoint && c > '0') { + coefficient_x++; + midpoint = 0; + rounded_up = 1; + } + if (c > '0') { + rounded = 1; + + if(dround) + { + dround = 0; + coefficient_x ++; + rounded_up = 1; + + if (coefficient_x == 10000000000000000ull) { + coefficient_x = 1000000000000000ull; + add_expon = 1; + } + } + } + } + ps++; + c = *ps; + } + + add_expon -= (dec_expon_scale + right_radix_leading_zeros); + + if (!c) { + #ifdef BID_SET_STATUS_FLAGS + if(rounded) + __set_status_flags (pfpsf, BID_INEXACT_EXCEPTION); +#endif + res = + fast_get_BID64_check_OF (sign_x, + add_expon + DECIMAL_EXPONENT_BIAS, + coefficient_x, 0, pfpsf); + BID_RETURN (res); + } + + if (c != 'E' && c != 'e') { + // return NaN + res = 0x7c00000000000000ull | sign_x; + BID_RETURN (res); + } + ps++; + c = *ps; + sgn_expon = (c == '-') ? 1 : 0; + if (c == '-' || c == '+') { + ps++; + c = *ps; + } + if (!c || c < '0' || c > '9') { + // return NaN + res = 0x7c00000000000000ull | sign_x; + BID_RETURN (res); + } + + while ((c >= '0') && (c <= '9')) { + if(expon_x<(1<<20)) { + expon_x = (expon_x << 1) + (expon_x << 3); + expon_x += (int) (c - '0'); } + + ps++; + c = *ps; + } + + if (c) { + // return NaN + res = 0x7c00000000000000ull | sign_x; + BID_RETURN (res); + } + +#ifdef BID_SET_STATUS_FLAGS + if(rounded) + __set_status_flags (pfpsf, BID_INEXACT_EXCEPTION); +#endif + + if (sgn_expon) + expon_x = -expon_x; + + expon_x += add_expon + DECIMAL_EXPONENT_BIAS; + + if (expon_x < 0) { + if (rounded_up) + coefficient_x--; + rnd_mode = 0; + res = + get_BID64_UF (sign_x, expon_x, coefficient_x, rounded, rnd_mode, + pfpsf); + BID_RETURN (res); + } + res = get_BID64 (sign_x, expon_x, coefficient_x, rnd_mode, pfpsf); + BID_RETURN (res); +} diff --git a/reftest/bid_conf.h b/reftest/bid_conf.h new file mode 100644 index 0000000..6b971c8 --- /dev/null +++ b/reftest/bid_conf.h @@ -0,0 +1,2059 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +#if defined(__cplusplus) +#define BID_EXTERN_C extern "C" +#else +#define BID_EXTERN_C extern +#endif + +#ifndef _BID_CONF_H +#define _BID_CONF_H + +// Name Changes + +#define _IDEC_glbflags __bid_IDEC_glbflags +#define _IDEC_glbround __bid_IDEC_glbround +#define _IDEC_glbexcepthandling __bid_IDEC_glbexcepthandling +#define _IDEC_glbexceptionmasks __bid_IDEC_glbexceptionmasks + +#define bid32_inf __bid32_inf +#define bid64_inf __bid64_inf +#define bid128_inf __bid128_inf +#define bid32_exp __bid32_exp +#define bid32_log __bid32_log +#define bid32_pow __bid32_pow +#define bid64_exp __bid64_exp +#define bid64_log __bid64_log +#define bid64_pow __bid64_pow +#define bid128_exp __bid128_exp +#define bid128_log __bid128_log +#define bid128_pow __bid128_pow +#define bid32_cbrt __bid32_cbrt +#define bid64_cbrt __bid64_cbrt +#define bid128_cbrt __bid128_cbrt +#define bid32_atan2 __bid32_atan2 +#define bid64_atan2 __bid64_atan2 +#define bid128_atan2 __bid128_atan2 +#define bid32_fmod __bid32_fmod +#define bid64_fmod __bid64_fmod +#define bid128_fmod __bid128_fmod +#define bid32_modf __bid32_modf +#define bid64_modf __bid64_modf +#define bid128_modf __bid128_modf +#define bid32_hypot __bid32_hypot +#define bid64_hypot __bid64_hypot +#define bid128_hypot __bid128_hypot +#define bid32_sin __bid32_sin +#define bid64_sin __bid64_sin +#define bid128_sin __bid128_sin +#define bid32_cos __bid32_cos +#define bid64_cos __bid64_cos +#define bid128_cos __bid128_cos +#define bid32_tan __bid32_tan +#define bid64_tan __bid64_tan +#define bid128_tan __bid128_tan +#define bid32_asin __bid32_asin +#define bid64_asin __bid64_asin +#define bid128_asin __bid128_asin +#define bid32_acos __bid32_acos +#define bid64_acos __bid64_acos +#define bid128_acos __bid128_acos +#define bid32_atan __bid32_atan +#define bid64_atan __bid64_atan +#define bid128_atan __bid128_atan +#define bid32_sinh __bid32_sinh +#define bid64_sinh __bid64_sinh +#define bid128_sinh __bid128_sinh +#define bid32_cosh __bid32_cosh +#define bid64_cosh __bid64_cosh +#define bid128_cosh __bid128_cosh +#define bid32_tanh __bid32_tanh +#define bid64_tanh __bid64_tanh +#define bid128_tanh __bid128_tanh +#define bid32_asinh __bid32_asinh +#define bid64_asinh __bid64_asinh +#define bid128_asinh __bid128_asinh +#define bid32_acosh __bid32_acosh +#define bid64_acosh __bid64_acosh +#define bid128_acosh __bid128_acosh +#define bid32_atanh __bid32_atanh +#define bid64_atanh __bid64_atanh +#define bid128_atanh __bid128_atanh +#define bid32_log1p __bid32_log1p +#define bid64_log1p __bid64_log1p +#define bid128_log1p __bid128_log1p +#define bid32_exp2 __bid32_exp2 +#define bid64_exp2 __bid64_exp2 +#define bid128_exp2 __bid128_exp2 +#define bid32_exp10 __bid32_exp10 +#define bid64_exp10 __bid64_exp10 +#define bid128_exp10 __bid128_exp10 +#define bid32_expm1 __bid32_expm1 +#define bid64_expm1 __bid64_expm1 +#define bid128_expm1 __bid128_expm1 +#define bid32_log10 __bid32_log10 +#define bid64_log10 __bid64_log10 +#define bid128_log10 __bid128_log10 +#define bid32_log2 __bid32_log2 +#define bid64_log2 __bid64_log2 +#define bid128_log2 __bid128_log2 +#define bid32_erf __bid32_erf +#define bid64_erf __bid64_erf +#define bid128_erf __bid128_erf +#define bid32_erfc __bid32_erfc +#define bid64_erfc __bid64_erfc +#define bid128_erfc __bid128_erfc +#define bid32_tgamma __bid32_tgamma +#define bid64_tgamma __bid64_tgamma +#define bid128_tgamma __bid128_tgamma +#define bid32_lgamma __bid32_lgamma +#define bid64_lgamma __bid64_lgamma +#define bid128_lgamma __bid128_lgamma + +#define bid32_frexp __bid32_frexp +#define bid64_frexp __bid64_frexp +#define bid128_frexp __bid128_frexp +#define bid32_logb __bid32_logb +#define bid64_logb __bid64_logb +#define bid128_logb __bid128_logb +#define bid32_scalbln __bid32_scalbln +#define bid64_scalbln __bid64_scalbln +#define bid128_scalbln __bid128_scalbln +#define bid32_nearbyint __bid32_nearbyint +#define bid64_nearbyint __bid64_nearbyint +#define bid128_nearbyint __bid128_nearbyint +#define bid32_lrint __bid32_lrint +#define bid64_lrint __bid64_lrint +#define bid128_lrint __bid128_lrint +#define bid32_llrint __bid32_llrint +#define bid64_llrint __bid64_llrint +#define bid128_llrint __bid128_llrint +#define bid32_lround __bid32_lround +#define bid64_lround __bid64_lround +#define bid128_lround __bid128_lround +#define bid32_llround __bid32_llround +#define bid64_llround __bid64_llround +#define bid128_llround __bid128_llround +#define bid32_nan __bid32_nan +#define bid64_nan __bid64_nan +#define bid128_nan __bid128_nan +#define bid32_nexttoward __bid32_nexttoward +#define bid64_nexttoward __bid64_nexttoward +#define bid128_nexttoward __bid128_nexttoward +#define bid32_fdim __bid32_fdim +#define bid64_fdim __bid64_fdim +#define bid128_fdim __bid128_fdim +#define bid32_quantexp __bid32_quantexp +#define bid64_quantexp __bid64_quantexp +#define bid128_quantexp __bid128_quantexp +#define bid32_quantum __bid32_quantum +#define bid64_quantum __bid64_quantum +#define bid128_quantum __bid128_quantum +#define bid32_llquantexp __bid32_llquantexp +#define bid64_llquantexp __bid64_llquantexp +#define bid128_llquantexp __bid128_llquantexp + +#define bid32_add __bid32_add +#define bid32_sub __bid32_sub +#define bid32_mul __bid32_mul +#define bid32_div __bid32_div +#define bid32_fma __bid32_fma +#define bid32_sqrt __bid32_sqrt +#define bid32_rem __bid32_rem +#define bid32_ilogb __bid32_ilogb +#define bid32_scalbn __bid32_scalbn +#define bid32_ldexp __bid32_ldexp +#define bid32_to_string __bid32_to_string +#define bid32_from_string __bid32_from_string +#define bid32_quantize __bid32_quantize +#define bid32_nextup __bid32_nextup +#define bid32_nextdown __bid32_nextdown +#define bid32_minnum __bid32_minnum +#define bid32_minnum_mag __bid32_minnum_mag +#define bid32_maxnum __bid32_maxnum +#define bid32_maxnum_mag __bid32_maxnum_mag +#define bid32_from_int32 __bid32_from_int32 +#define bid32_from_uint32 __bid32_from_uint32 +#define bid32_from_int64 __bid32_from_int64 +#define bid32_from_uint64 __bid32_from_uint64 +#define bid32_isSigned __bid32_isSigned +#define bid32_isNormal __bid32_isNormal +#define bid32_isSubnormal __bid32_isSubnormal +#define bid32_isFinite __bid32_isFinite +#define bid32_isZero __bid32_isZero +#define bid32_isInf __bid32_isInf +#define bid32_isSignaling __bid32_isSignaling +#define bid32_isNaN __bid32_isNaN +#define bid32_copy __bid32_copy +#define bid32_negate __bid32_negate +#define bid32_abs __bid32_abs +#define bid32_copySign __bid32_copySign +#define bid32_class __bid32_class +#define bid32_sameQuantum __bid32_sameQuantum +#define bid32_totalOrder __bid32_totalOrder +#define bid32_totalOrderMag __bid32_totalOrderMag +#define bid32_radix __bid32_radix +#define bid32_quiet_equal __bid32_quiet_equal +#define bid32_quiet_greater __bid32_quiet_greater +#define bid32_quiet_greater_equal __bid32_quiet_greater_equal +#define bid32_quiet_greater_unordered __bid32_quiet_greater_unordered +#define bid32_quiet_less __bid32_quiet_less +#define bid32_quiet_less_equal __bid32_quiet_less_equal +#define bid32_quiet_less_unordered __bid32_quiet_less_unordered +#define bid32_quiet_not_equal __bid32_quiet_not_equal +#define bid32_quiet_not_greater __bid32_quiet_not_greater +#define bid32_quiet_not_less __bid32_quiet_not_less +#define bid32_quiet_ordered __bid32_quiet_ordered +#define bid32_quiet_unordered __bid32_quiet_unordered +#define bid32_signaling_greater __bid32_signaling_greater +#define bid32_signaling_greater_equal __bid32_signaling_greater_equal +#define bid32_signaling_greater_unordered __bid32_signaling_greater_unordered +#define bid32_signaling_less __bid32_signaling_less +#define bid32_signaling_less_equal __bid32_signaling_less_equal +#define bid32_signaling_less_unordered __bid32_signaling_less_unordered +#define bid32_signaling_not_greater __bid32_signaling_not_greater +#define bid32_signaling_not_less __bid32_signaling_not_less +#define bid32_isCanonical __bid32_isCanonical +#define bid32_nextafter __bid32_nextafter +#define bid32_round_integral_exact __bid32_round_integral_exact +#define bid32_round_integral_nearest_away __bid32_round_integral_nearest_away +#define bid32_round_integral_nearest_even __bid32_round_integral_nearest_even +#define bid32_round_integral_negative __bid32_round_integral_negative +#define bid32_round_integral_positive __bid32_round_integral_positive +#define bid32_round_integral_zero __bid32_round_integral_zero +#define bid32_to_int16_ceil __bid32_to_int16_ceil +#define bid32_to_int16_floor __bid32_to_int16_floor +#define bid32_to_int16_int __bid32_to_int16_int +#define bid32_to_int16_rnint __bid32_to_int16_rnint +#define bid32_to_int16_rninta __bid32_to_int16_rninta +#define bid32_to_int16_xceil __bid32_to_int16_xceil +#define bid32_to_int16_xfloor __bid32_to_int16_xfloor +#define bid32_to_int16_xint __bid32_to_int16_xint +#define bid32_to_int16_xrnint __bid32_to_int16_xrnint +#define bid32_to_int16_xrninta __bid32_to_int16_xrninta +#define bid32_to_int32_ceil __bid32_to_int32_ceil +#define bid32_to_int32_floor __bid32_to_int32_floor +#define bid32_to_int32_int __bid32_to_int32_int +#define bid32_to_int32_rnint __bid32_to_int32_rnint +#define bid32_to_int32_rninta __bid32_to_int32_rninta +#define bid32_to_int32_xceil __bid32_to_int32_xceil +#define bid32_to_int32_xfloor __bid32_to_int32_xfloor +#define bid32_to_int32_xint __bid32_to_int32_xint +#define bid32_to_int32_xrnint __bid32_to_int32_xrnint +#define bid32_to_int32_xrninta __bid32_to_int32_xrninta +#define bid32_to_int64_ceil __bid32_to_int64_ceil +#define bid32_to_int64_floor __bid32_to_int64_floor +#define bid32_to_int64_int __bid32_to_int64_int +#define bid32_to_int64_rnint __bid32_to_int64_rnint +#define bid32_to_int64_rninta __bid32_to_int64_rninta +#define bid32_to_int64_xceil __bid32_to_int64_xceil +#define bid32_to_int64_xfloor __bid32_to_int64_xfloor +#define bid32_to_int64_xint __bid32_to_int64_xint +#define bid32_to_int64_xrnint __bid32_to_int64_xrnint +#define bid32_to_int64_xrninta __bid32_to_int64_xrninta +#define bid32_to_int8_ceil __bid32_to_int8_ceil +#define bid32_to_int8_floor __bid32_to_int8_floor +#define bid32_to_int8_int __bid32_to_int8_int +#define bid32_to_int8_rnint __bid32_to_int8_rnint +#define bid32_to_int8_rninta __bid32_to_int8_rninta +#define bid32_to_int8_xceil __bid32_to_int8_xceil +#define bid32_to_int8_xfloor __bid32_to_int8_xfloor +#define bid32_to_int8_xint __bid32_to_int8_xint +#define bid32_to_int8_xrnint __bid32_to_int8_xrnint +#define bid32_to_int8_xrninta __bid32_to_int8_xrninta +#define bid32_to_uint16_ceil __bid32_to_uint16_ceil +#define bid32_to_uint16_floor __bid32_to_uint16_floor +#define bid32_to_uint16_int __bid32_to_uint16_int +#define bid32_to_uint16_rnint __bid32_to_uint16_rnint +#define bid32_to_uint16_rninta __bid32_to_uint16_rninta +#define bid32_to_uint16_xceil __bid32_to_uint16_xceil +#define bid32_to_uint16_xfloor __bid32_to_uint16_xfloor +#define bid32_to_uint16_xint __bid32_to_uint16_xint +#define bid32_to_uint16_xrnint __bid32_to_uint16_xrnint +#define bid32_to_uint16_xrninta __bid32_to_uint16_xrninta +#define bid32_to_uint32_ceil __bid32_to_uint32_ceil +#define bid32_to_uint32_floor __bid32_to_uint32_floor +#define bid32_to_uint32_int __bid32_to_uint32_int +#define bid32_to_uint32_rnint __bid32_to_uint32_rnint +#define bid32_to_uint32_rninta __bid32_to_uint32_rninta +#define bid32_to_uint32_xceil __bid32_to_uint32_xceil +#define bid32_to_uint32_xfloor __bid32_to_uint32_xfloor +#define bid32_to_uint32_xint __bid32_to_uint32_xint +#define bid32_to_uint32_xrnint __bid32_to_uint32_xrnint +#define bid32_to_uint32_xrninta __bid32_to_uint32_xrninta +#define bid32_to_uint64_ceil __bid32_to_uint64_ceil +#define bid32_to_uint64_floor __bid32_to_uint64_floor +#define bid32_to_uint64_int __bid32_to_uint64_int +#define bid32_to_uint64_rnint __bid32_to_uint64_rnint +#define bid32_to_uint64_rninta __bid32_to_uint64_rninta +#define bid32_to_uint64_xceil __bid32_to_uint64_xceil +#define bid32_to_uint64_xfloor __bid32_to_uint64_xfloor +#define bid32_to_uint64_xint __bid32_to_uint64_xint +#define bid32_to_uint64_xrnint __bid32_to_uint64_xrnint +#define bid32_to_uint64_xrninta __bid32_to_uint64_xrninta +#define bid32_to_uint8_ceil __bid32_to_uint8_ceil +#define bid32_to_uint8_floor __bid32_to_uint8_floor +#define bid32_to_uint8_int __bid32_to_uint8_int +#define bid32_to_uint8_rnint __bid32_to_uint8_rnint +#define bid32_to_uint8_rninta __bid32_to_uint8_rninta +#define bid32_to_uint8_xceil __bid32_to_uint8_xceil +#define bid32_to_uint8_xfloor __bid32_to_uint8_xfloor +#define bid32_to_uint8_xint __bid32_to_uint8_xint +#define bid32_to_uint8_xrnint __bid32_to_uint8_xrnint +#define bid32_to_uint8_xrninta __bid32_to_uint8_xrninta + +#define bid64_add __bid64_add +#define bid64_sub __bid64_sub +#define bid64_mul __bid64_mul +#define bid64_div __bid64_div +#define bid64dq_div __bid64dq_div +#define bid64qd_div __bid64qd_div +#define bid64qq_div __bid64qq_div +#define bid64q_sqrt __bid64q_sqrt +#define bid64_sqrt __bid64_sqrt +#define bid64_rem __bid64_rem +#define bid64_fma __bid64_fma +#define bid64_scalbn __bid64_scalbn +#define bid64_ldexp __bid64_ldexp +#define bid_round128_19_38 __bid_round128_19_38 +#define bid_round192_39_57 __bid_round192_39_57 +#define bid_round256_58_76 __bid_round256_58_76 +#define bid_round64_2_18 __bid_round64_2_18 +#define bid64_nextafter __bid64_nextafter +#define bid64_nextdown __bid64_nextdown +#define bid64_nextup __bid64_nextup +#define bid_b2d __bid_b2d +#define bid_b2d2 __bid_b2d2 +#define bid_b2d3 __bid_b2d3 +#define bid_b2d4 __bid_b2d4 +#define bid_b2d5 __bid_b2d5 +#define bid_to_dpd128 __bid_to_dpd128 +#define bid_to_dpd32 __bid_to_dpd32 +#define bid_to_dpd64 __bid_to_dpd64 +#define bid_d2b __bid_d2b +#define bid_d2b2 __bid_d2b2 +#define bid_d2b3 __bid_d2b3 +#define bid_d2b4 __bid_d2b4 +#define bid_d2b5 __bid_d2b5 +#define bid_d2b6 __bid_d2b6 +#define bid_dpd_to_bid128 __bid_dpd_to_bid128 +#define bid_dpd_to_bid32 __bid_dpd_to_bid32 +#define bid_dpd_to_bid64 __bid_dpd_to_bid64 +#define bid128_nextafter __bid128_nextafter +#define bid128_nextdown __bid128_nextdown +#define bid128_nextup __bid128_nextup +#define bid64_ilogb __bid64_ilogb +#define bid64_quantize __bid64_quantize +#define bid_estimate_bin_expon __bid_estimate_bin_expon +#define bid_estimate_decimal_digits __bid_estimate_decimal_digits +#define bid_power10_index_binexp __bid_power10_index_binexp +#define bid_power10_index_binexp_128 __bid_power10_index_binexp_128 +#define bid_power10_table_128 __bid_power10_table_128 +#define bid_reciprocals10_128 __bid_reciprocals10_128 +#define bid_reciprocals10_64 __bid_reciprocals10_64 +#define bid_recip_scale __bid_recip_scale +#define bid_round_const_table __bid_round_const_table +#define bid_round_const_table_128 __bid_round_const_table_128 +#define bid_short_recip_scale __bid_short_recip_scale +#define bid64_from_string __bid64_from_string +#define bid64_to_string __bid64_to_string +#define bid_Inv_Tento9 __bid_Inv_Tento9 +#define bid_midi_tbl __bid_midi_tbl +#define bid_Tento3 __bid_Tento3 +#define bid_Tento6 __bid_Tento6 +#define bid_Tento9 __bid_Tento9 +#define bid_Twoto30_m_10to9 __bid_Twoto30_m_10to9 +#define bid_Twoto60 __bid_Twoto60 +#define bid_Twoto60_m_10to18 __bid_Twoto60_m_10to18 +#define bid_convert_table __bid_convert_table +#define bid_factors __bid_factors +#define bid_packed_10000_zeros __bid_packed_10000_zeros +#define bid_char_table2 __bid_char_table2 +#define bid_char_table3 __bid_char_table3 +#define bid_Ex128m128 __bid_Ex128m128 +#define bid_Ex192m192 __bid_Ex192m192 +#define bid_Ex256m256 __bid_Ex256m256 +#define bid_Ex64m64 __bid_Ex64m64 +#define bid_half128 __bid_half128 +#define bid_half192 __bid_half192 +#define bid_half256 __bid_half256 +#define bid_half64 __bid_half64 +#define bid_Kx128 __bid_Kx128 +#define bid_Kx192 __bid_Kx192 +#define bid_Kx256 __bid_Kx256 +#define bid_Kx64 __bid_Kx64 +#define bid_mask128 __bid_mask128 +#define bid_mask192 __bid_mask192 +#define bid_mask256 __bid_mask256 +#define bid_mask64 __bid_mask64 +#define bid_maskhigh128 __bid_maskhigh128 +#define bid_maskhigh128M __bid_maskhigh128M +#define bid_maskhigh192M __bid_maskhigh192M +#define bid_maskhigh256M __bid_maskhigh256M +#define bid_midpoint128 __bid_midpoint128 +#define bid_midpoint192 __bid_midpoint192 +#define bid_midpoint256 __bid_midpoint256 +#define bid_midpoint64 __bid_midpoint64 +#define bid_nr_digits __bid_nr_digits +#define bid_onehalf128 __bid_onehalf128 +#define bid_onehalf128M __bid_onehalf128M +#define bid_onehalf192M __bid_onehalf192M +#define bid_onehalf256M __bid_onehalf256M +#define bid_shiftright128 __bid_shiftright128 +#define bid_shiftright128M __bid_shiftright128M +#define bid_shiftright192M __bid_shiftright192M +#define bid_shiftright256M __bid_shiftright256M +#define bid_shift_ten2m3k128 __bid_shift_ten2m3k128 +#define bid_shift_ten2m3k64 __bid_shift_ten2m3k64 +#define bid_ten2k128 __bid_ten2k128 +#define bid_ten2k256 __bid_ten2k256 +#define bid_ten2k64 __bid_ten2k64 +#define bid_ten2m3k128 __bid_ten2m3k128 +#define bid_ten2m3k64 __bid_ten2m3k64 +#define bid_ten2mk128 __bid_ten2mk128 +#define bid_ten2mk128M __bid_ten2mk128M +#define bid_ten2mk128trunc __bid_ten2mk128trunc +#define bid_ten2mk128truncM __bid_ten2mk128truncM +#define bid_ten2mk192M __bid_ten2mk192M +#define bid_ten2mk192truncM __bid_ten2mk192truncM +#define bid_ten2mk256M __bid_ten2mk256M +#define bid_ten2mk256truncM __bid_ten2mk256truncM +#define bid_ten2mk64 __bid_ten2mk64 +#define bid_ten2mxtrunc128 __bid_ten2mxtrunc128 +#define bid_ten2mxtrunc192 __bid_ten2mxtrunc192 +#define bid_ten2mxtrunc256 __bid_ten2mxtrunc256 +#define bid_ten2mxtrunc64 __bid_ten2mxtrunc64 +#define bid128_add __bid128_add +#define bid128dd_add __bid128dd_add +#define bid128dd_sub __bid128dd_sub +#define bid128dq_add __bid128dq_add +#define bid128dq_sub __bid128dq_sub +#define bid128qd_add __bid128qd_add +#define bid128qd_sub __bid128qd_sub +#define bid128_sub __bid128_sub +#define bid64dq_add __bid64dq_add +#define bid64dq_sub __bid64dq_sub +#define bid64qd_add __bid64qd_add +#define bid64qd_sub __bid64qd_sub +#define bid64qq_add __bid64qq_add +#define bid64qq_sub __bid64qq_sub +#define bid128dd_mul __bid128dd_mul +#define bid128dq_mul __bid128dq_mul +#define bid128_mul __bid128_mul +#define bid128qd_mul __bid128qd_mul +#define bid64dq_mul __bid64dq_mul +#define bid64qd_mul __bid64qd_mul +#define bid64qq_mul __bid64qq_mul +#define bid128dd_div __bid128dd_div +#define bid128_div __bid128_div +#define bid128dq_div __bid128dq_div +#define bid128qd_div __bid128qd_div +#define bid128d_sqrt __bid128d_sqrt +#define bid128_sqrt __bid128_sqrt +#define bid128ddd_fma __bid128ddd_fma +#define bid128ddq_fma __bid128ddq_fma +#define bid128dqd_fma __bid128dqd_fma +#define bid128dqq_fma __bid128dqq_fma +#define bid128_fma __bid128_fma +#define bid128qdd_fma __bid128qdd_fma +#define bid128qdq_fma __bid128qdq_fma +#define bid128qqd_fma __bid128qqd_fma +#define bid64ddq_fma __bid64ddq_fma +#define bid64dqd_fma __bid64dqd_fma +#define bid64dqq_fma __bid64dqq_fma +#define bid64qdd_fma __bid64qdd_fma +#define bid64qdq_fma __bid64qdq_fma +#define bid64qqd_fma __bid64qqd_fma +#define bid64qqq_fma __bid64qqq_fma +#define bid128_round_integral_exact __bid128_round_integral_exact +#define bid128_round_integral_nearest_away __bid128_round_integral_nearest_away +#define bid128_round_integral_nearest_even __bid128_round_integral_nearest_even +#define bid128_round_integral_negative __bid128_round_integral_negative +#define bid128_round_integral_positive __bid128_round_integral_positive +#define bid128_round_integral_zero __bid128_round_integral_zero +#define bid64_round_integral_exact __bid64_round_integral_exact +#define bid64_round_integral_nearest_away __bid64_round_integral_nearest_away +#define bid64_round_integral_nearest_even __bid64_round_integral_nearest_even +#define bid64_round_integral_negative __bid64_round_integral_negative +#define bid64_round_integral_positive __bid64_round_integral_positive +#define bid64_round_integral_zero __bid64_round_integral_zero +#define bid128_quantize __bid128_quantize +#define bid128_scalbn __bid128_scalbn +#define bid128_ldexp __bid128_ldexp +#define bid64_maxnum __bid64_maxnum +#define bid64_maxnum_mag __bid64_maxnum_mag +#define bid64_minnum __bid64_minnum +#define bid64_minnum_mag __bid64_minnum_mag +#define bid128_maxnum __bid128_maxnum +#define bid128_maxnum_mag __bid128_maxnum_mag +#define bid128_minnum __bid128_minnum +#define bid128_minnum_mag __bid128_minnum_mag +#define bid128_rem __bid128_rem +#define bid128_ilogb __bid128_ilogb +#define bid_getDecimalRoundingDirection __bid_getDecimalRoundingDirection +#define bid_is754 __bid_is754 +#define bid_is754R __bid_is754R +#define bid_signalException __bid_signalException +#define bid_lowerFlags __bid_lowerFlags +#define bid_restoreFlags __bid_restoreFlags +#define bid_saveFlags __bid_saveFlags +#define bid_setDecimalRoundingDirection __bid_setDecimalRoundingDirection +#define bid_testFlags __bid_testFlags +#define bid_testSavedFlags __bid_testSavedFlags +#define bid32_to_bid64 __bid32_to_bid64 +#define bid64_to_bid32 __bid64_to_bid32 +#define bid128_to_string __bid128_to_string +#define mod10_18_tbl __bid_mod10_18_tbl +#define bid128_to_bid32 __bid128_to_bid32 +#define bid32_to_bid128 __bid32_to_bid128 +#define bid128_to_bid64 __bid128_to_bid64 +#define bid64_to_bid128 __bid64_to_bid128 +#define bid128_from_string __bid128_from_string +#define bid128_from_int32 __bid128_from_int32 +#define bid128_from_int64 __bid128_from_int64 +#define bid128_from_uint32 __bid128_from_uint32 +#define bid128_from_uint64 __bid128_from_uint64 +#define bid64_from_int32 __bid64_from_int32 +#define bid64_from_int64 __bid64_from_int64 +#define bid64_from_uint32 __bid64_from_uint32 +#define bid64_from_uint64 __bid64_from_uint64 +#define bid64_abs __bid64_abs +#define bid64_class __bid64_class +#define bid64_copy __bid64_copy +#define bid64_copySign __bid64_copySign +#define bid64_isCanonical __bid64_isCanonical +#define bid64_isFinite __bid64_isFinite +#define bid64_isInf __bid64_isInf +#define bid64_isNaN __bid64_isNaN +#define bid64_isNormal __bid64_isNormal +#define bid64_isSignaling __bid64_isSignaling +#define bid64_isSigned __bid64_isSigned +#define bid64_isSubnormal __bid64_isSubnormal +#define bid64_isZero __bid64_isZero +#define bid64_negate __bid64_negate +#define bid64_radix __bid64_radix +#define bid64_sameQuantum __bid64_sameQuantum +#define bid64_totalOrder __bid64_totalOrder +#define bid64_totalOrderMag __bid64_totalOrderMag +#define bid128_abs __bid128_abs +#define bid128_class __bid128_class +#define bid128_copy __bid128_copy +#define bid128_copySign __bid128_copySign +#define bid128_isCanonical __bid128_isCanonical +#define bid128_isFinite __bid128_isFinite +#define bid128_isInf __bid128_isInf +#define bid128_isNaN __bid128_isNaN +#define bid128_isNormal __bid128_isNormal +#define bid128_isSignaling __bid128_isSignaling +#define bid128_isSigned __bid128_isSigned +#define bid128_isSubnormal __bid128_isSubnormal +#define bid128_isZero __bid128_isZero +#define bid128_negate __bid128_negate +#define bid128_radix __bid128_radix +#define bid128_sameQuantum __bid128_sameQuantum +#define bid128_totalOrder __bid128_totalOrder +#define bid128_totalOrderMag __bid128_totalOrderMag +#define bid64_quiet_equal __bid64_quiet_equal +#define bid64_quiet_greater __bid64_quiet_greater +#define bid64_quiet_greater_equal __bid64_quiet_greater_equal +#define bid64_quiet_greater_unordered __bid64_quiet_greater_unordered +#define bid64_quiet_less __bid64_quiet_less +#define bid64_quiet_less_equal __bid64_quiet_less_equal +#define bid64_quiet_less_unordered __bid64_quiet_less_unordered +#define bid64_quiet_not_equal __bid64_quiet_not_equal +#define bid64_quiet_not_greater __bid64_quiet_not_greater +#define bid64_quiet_not_less __bid64_quiet_not_less +#define bid64_quiet_ordered __bid64_quiet_ordered +#define bid64_quiet_unordered __bid64_quiet_unordered +#define bid64_signaling_greater __bid64_signaling_greater +#define bid64_signaling_greater_equal __bid64_signaling_greater_equal +#define bid64_signaling_greater_unordered __bid64_signaling_greater_unordered +#define bid64_signaling_less __bid64_signaling_less +#define bid64_signaling_less_equal __bid64_signaling_less_equal +#define bid64_signaling_less_unordered __bid64_signaling_less_unordered +#define bid64_signaling_not_greater __bid64_signaling_not_greater +#define bid64_signaling_not_less __bid64_signaling_not_less +#define bid128_quiet_equal __bid128_quiet_equal +#define bid128_quiet_greater __bid128_quiet_greater +#define bid128_quiet_greater_equal __bid128_quiet_greater_equal +#define bid128_quiet_greater_unordered __bid128_quiet_greater_unordered +#define bid128_quiet_less __bid128_quiet_less +#define bid128_quiet_less_equal __bid128_quiet_less_equal +#define bid128_quiet_less_unordered __bid128_quiet_less_unordered +#define bid128_quiet_not_equal __bid128_quiet_not_equal +#define bid128_quiet_not_greater __bid128_quiet_not_greater +#define bid128_quiet_not_less __bid128_quiet_not_less +#define bid128_quiet_ordered __bid128_quiet_ordered +#define bid128_quiet_unordered __bid128_quiet_unordered +#define bid128_signaling_greater __bid128_signaling_greater +#define bid128_signaling_greater_equal __bid128_signaling_greater_equal +#define bid128_signaling_greater_unordered __bid128_signaling_greater_unordered +#define bid128_signaling_less __bid128_signaling_less +#define bid128_signaling_less_equal __bid128_signaling_less_equal +#define bid128_signaling_less_unordered __bid128_signaling_less_unordered +#define bid128_signaling_not_greater __bid128_signaling_not_greater +#define bid128_signaling_not_less __bid128_signaling_not_less +#define bid64_to_int32_ceil __bid64_to_int32_ceil +#define bid64_to_int32_floor __bid64_to_int32_floor +#define bid64_to_int32_int __bid64_to_int32_int +#define bid64_to_int32_rnint __bid64_to_int32_rnint +#define bid64_to_int32_rninta __bid64_to_int32_rninta +#define bid64_to_int32_xceil __bid64_to_int32_xceil +#define bid64_to_int32_xfloor __bid64_to_int32_xfloor +#define bid64_to_int32_xint __bid64_to_int32_xint +#define bid64_to_int32_xrnint __bid64_to_int32_xrnint +#define bid64_to_int32_xrninta __bid64_to_int32_xrninta +#define bid64_to_uint32_ceil __bid64_to_uint32_ceil +#define bid64_to_uint32_floor __bid64_to_uint32_floor +#define bid64_to_uint32_int __bid64_to_uint32_int +#define bid64_to_uint32_rnint __bid64_to_uint32_rnint +#define bid64_to_uint32_rninta __bid64_to_uint32_rninta +#define bid64_to_uint32_xceil __bid64_to_uint32_xceil +#define bid64_to_uint32_xfloor __bid64_to_uint32_xfloor +#define bid64_to_uint32_xint __bid64_to_uint32_xint +#define bid64_to_uint32_xrnint __bid64_to_uint32_xrnint +#define bid64_to_uint32_xrninta __bid64_to_uint32_xrninta +#define bid64_to_int64_ceil __bid64_to_int64_ceil +#define bid64_to_int64_floor __bid64_to_int64_floor +#define bid64_to_int64_int __bid64_to_int64_int +#define bid64_to_int64_rnint __bid64_to_int64_rnint +#define bid64_to_int64_rninta __bid64_to_int64_rninta +#define bid64_to_int64_xceil __bid64_to_int64_xceil +#define bid64_to_int64_xfloor __bid64_to_int64_xfloor +#define bid64_to_int64_xint __bid64_to_int64_xint +#define bid64_to_int64_xrnint __bid64_to_int64_xrnint +#define bid64_to_int64_xrninta __bid64_to_int64_xrninta +#define bid64_to_uint64_ceil __bid64_to_uint64_ceil +#define bid64_to_uint64_floor __bid64_to_uint64_floor +#define bid64_to_uint64_int __bid64_to_uint64_int +#define bid64_to_uint64_rnint __bid64_to_uint64_rnint +#define bid64_to_uint64_rninta __bid64_to_uint64_rninta +#define bid64_to_uint64_xceil __bid64_to_uint64_xceil +#define bid64_to_uint64_xfloor __bid64_to_uint64_xfloor +#define bid64_to_uint64_xint __bid64_to_uint64_xint +#define bid64_to_uint64_xrnint __bid64_to_uint64_xrnint +#define bid64_to_uint64_xrninta __bid64_to_uint64_xrninta +#define bid128_to_int32_ceil __bid128_to_int32_ceil +#define bid128_to_int32_floor __bid128_to_int32_floor +#define bid128_to_int32_int __bid128_to_int32_int +#define bid128_to_int32_rnint __bid128_to_int32_rnint +#define bid128_to_int32_rninta __bid128_to_int32_rninta +#define bid128_to_int32_xceil __bid128_to_int32_xceil +#define bid128_to_int32_xfloor __bid128_to_int32_xfloor +#define bid128_to_int32_xint __bid128_to_int32_xint +#define bid128_to_int32_xrnint __bid128_to_int32_xrnint +#define bid128_to_int32_xrninta __bid128_to_int32_xrninta +#define bid128_to_uint32_ceil __bid128_to_uint32_ceil +#define bid128_to_uint32_floor __bid128_to_uint32_floor +#define bid128_to_uint32_int __bid128_to_uint32_int +#define bid128_to_uint32_rnint __bid128_to_uint32_rnint +#define bid128_to_uint32_rninta __bid128_to_uint32_rninta +#define bid128_to_uint32_xceil __bid128_to_uint32_xceil +#define bid128_to_uint32_xfloor __bid128_to_uint32_xfloor +#define bid128_to_uint32_xint __bid128_to_uint32_xint +#define bid128_to_uint32_xrnint __bid128_to_uint32_xrnint +#define bid128_to_uint32_xrninta __bid128_to_uint32_xrninta +#define bid128_to_int64_ceil __bid128_to_int64_ceil +#define bid128_to_int64_floor __bid128_to_int64_floor +#define bid128_to_int64_int __bid128_to_int64_int +#define bid128_to_int64_rnint __bid128_to_int64_rnint +#define bid128_to_int64_rninta __bid128_to_int64_rninta +#define bid128_to_int64_xceil __bid128_to_int64_xceil +#define bid128_to_int64_xfloor __bid128_to_int64_xfloor +#define bid128_to_int64_xint __bid128_to_int64_xint +#define bid128_to_int64_xrnint __bid128_to_int64_xrnint +#define bid128_to_int64_xrninta __bid128_to_int64_xrninta +#define bid128_to_uint64_ceil __bid128_to_uint64_ceil +#define bid128_to_uint64_floor __bid128_to_uint64_floor +#define bid128_to_uint64_int __bid128_to_uint64_int +#define bid128_to_uint64_rnint __bid128_to_uint64_rnint +#define bid128_to_uint64_rninta __bid128_to_uint64_rninta +#define bid128_to_uint64_xceil __bid128_to_uint64_xceil +#define bid128_to_uint64_xfloor __bid128_to_uint64_xfloor +#define bid128_to_uint64_xint __bid128_to_uint64_xint +#define bid128_to_uint64_xrnint __bid128_to_uint64_xrnint +#define bid128_to_uint64_xrninta __bid128_to_uint64_xrninta +#define bid128_to_binary128 __bid128_to_binary128 +#define bid128_to_binary32 __bid128_to_binary32 +#define bid128_to_binary64 __bid128_to_binary64 +#define bid128_to_binary80 __bid128_to_binary80 +#define bid32_to_binary128 __bid32_to_binary128 +#define bid32_to_binary32 __bid32_to_binary32 +#define bid32_to_binary64 __bid32_to_binary64 +#define bid32_to_binary80 __bid32_to_binary80 +#define bid64_to_binary128 __bid64_to_binary128 +#define bid64_to_binary32 __bid64_to_binary32 +#define bid64_to_binary64 __bid64_to_binary64 +#define bid64_to_binary80 __bid64_to_binary80 +#define binary128_to_bid128 __binary128_to_bid128 +#define binary128_to_bid32 __binary128_to_bid32 +#define binary128_to_bid64 __binary128_to_bid64 +#define binary32_to_bid128 __binary32_to_bid128 +#define binary32_to_bid32 __binary32_to_bid32 +#define binary32_to_bid64 __binary32_to_bid64 +#define binary64_to_bid128 __binary64_to_bid128 +#define binary64_to_bid32 __binary64_to_bid32 +#define binary64_to_bid64 __binary64_to_bid64 +#define binary80_to_bid128 __binary80_to_bid128 +#define binary80_to_bid32 __binary80_to_bid32 +#define binary80_to_bid64 __binary80_to_bid64 +#define bid64_to_uint16_ceil __bid64_to_uint16_ceil +#define bid64_to_uint16_floor __bid64_to_uint16_floor +#define bid64_to_uint16_int __bid64_to_uint16_int +#define bid64_to_uint16_rnint __bid64_to_uint16_rnint +#define bid64_to_uint16_rninta __bid64_to_uint16_rninta +#define bid64_to_uint16_xceil __bid64_to_uint16_xceil +#define bid64_to_uint16_xfloor __bid64_to_uint16_xfloor +#define bid64_to_uint16_xint __bid64_to_uint16_xint +#define bid64_to_uint16_xrnint __bid64_to_uint16_xrnint +#define bid64_to_uint16_xrninta __bid64_to_uint16_xrninta +#define bid64_to_int16_ceil __bid64_to_int16_ceil +#define bid64_to_int16_floor __bid64_to_int16_floor +#define bid64_to_int16_int __bid64_to_int16_int +#define bid64_to_int16_rnint __bid64_to_int16_rnint +#define bid64_to_int16_rninta __bid64_to_int16_rninta +#define bid64_to_int16_xceil __bid64_to_int16_xceil +#define bid64_to_int16_xfloor __bid64_to_int16_xfloor +#define bid64_to_int16_xint __bid64_to_int16_xint +#define bid64_to_int16_xrnint __bid64_to_int16_xrnint +#define bid64_to_int16_xrninta __bid64_to_int16_xrninta +#define bid128_to_uint16_ceil __bid128_to_uint16_ceil +#define bid128_to_uint16_floor __bid128_to_uint16_floor +#define bid128_to_uint16_int __bid128_to_uint16_int +#define bid128_to_uint16_rnint __bid128_to_uint16_rnint +#define bid128_to_uint16_rninta __bid128_to_uint16_rninta +#define bid128_to_uint16_xceil __bid128_to_uint16_xceil +#define bid128_to_uint16_xfloor __bid128_to_uint16_xfloor +#define bid128_to_uint16_xint __bid128_to_uint16_xint +#define bid128_to_uint16_xrnint __bid128_to_uint16_xrnint +#define bid128_to_uint16_xrninta __bid128_to_uint16_xrninta +#define bid128_to_int16_ceil __bid128_to_int16_ceil +#define bid128_to_int16_floor __bid128_to_int16_floor +#define bid128_to_int16_int __bid128_to_int16_int +#define bid128_to_int16_rnint __bid128_to_int16_rnint +#define bid128_to_int16_rninta __bid128_to_int16_rninta +#define bid128_to_int16_xceil __bid128_to_int16_xceil +#define bid128_to_int16_xfloor __bid128_to_int16_xfloor +#define bid128_to_int16_xint __bid128_to_int16_xint +#define bid128_to_int16_xrnint __bid128_to_int16_xrnint +#define bid128_to_int16_xrninta __bid128_to_int16_xrninta +#define bid64_to_uint8_ceil __bid64_to_uint8_ceil +#define bid64_to_uint8_floor __bid64_to_uint8_floor +#define bid64_to_uint8_int __bid64_to_uint8_int +#define bid64_to_uint8_rnint __bid64_to_uint8_rnint +#define bid64_to_uint8_rninta __bid64_to_uint8_rninta +#define bid64_to_uint8_xceil __bid64_to_uint8_xceil +#define bid64_to_uint8_xfloor __bid64_to_uint8_xfloor +#define bid64_to_uint8_xint __bid64_to_uint8_xint +#define bid64_to_uint8_xrnint __bid64_to_uint8_xrnint +#define bid64_to_uint8_xrninta __bid64_to_uint8_xrninta +#define bid64_to_int8_ceil __bid64_to_int8_ceil +#define bid64_to_int8_floor __bid64_to_int8_floor +#define bid64_to_int8_int __bid64_to_int8_int +#define bid64_to_int8_rnint __bid64_to_int8_rnint +#define bid64_to_int8_rninta __bid64_to_int8_rninta +#define bid64_to_int8_xceil __bid64_to_int8_xceil +#define bid64_to_int8_xfloor __bid64_to_int8_xfloor +#define bid64_to_int8_xint __bid64_to_int8_xint +#define bid64_to_int8_xrnint __bid64_to_int8_xrnint +#define bid64_to_int8_xrninta __bid64_to_int8_xrninta +#define bid128_to_uint8_ceil __bid128_to_uint8_ceil +#define bid128_to_uint8_floor __bid128_to_uint8_floor +#define bid128_to_uint8_int __bid128_to_uint8_int +#define bid128_to_uint8_rnint __bid128_to_uint8_rnint +#define bid128_to_uint8_rninta __bid128_to_uint8_rninta +#define bid128_to_uint8_xceil __bid128_to_uint8_xceil +#define bid128_to_uint8_xfloor __bid128_to_uint8_xfloor +#define bid128_to_uint8_xint __bid128_to_uint8_xint +#define bid128_to_uint8_xrnint __bid128_to_uint8_xrnint +#define bid128_to_uint8_xrninta __bid128_to_uint8_xrninta +#define bid128_to_int8_ceil __bid128_to_int8_ceil +#define bid128_to_int8_floor __bid128_to_int8_floor +#define bid128_to_int8_int __bid128_to_int8_int +#define bid128_to_int8_rnint __bid128_to_int8_rnint +#define bid128_to_int8_rninta __bid128_to_int8_rninta +#define bid128_to_int8_xceil __bid128_to_int8_xceil +#define bid128_to_int8_xfloor __bid128_to_int8_xfloor +#define bid128_to_int8_xint __bid128_to_int8_xint +#define bid128_to_int8_xrnint __bid128_to_int8_xrnint +#define bid128_to_int8_xrninta __bid128_to_int8_xrninta + +#define bid32_inf __bid32_inf +#define bid64_inf __bid64_inf +#define bid128_inf __bid128_inf + +#define bid_feclearexcept __bid_feclearexcept +#define bid_fegetexceptflag __bid_fegetexceptflag +#define bid_feraiseexcept __bid_feraiseexcept +#define bid_fesetexceptflag __bid_fesetexceptflag +#define bid_fetestexcept __bid_fetestexcept + +#define bid_strtod128 __bid_strtod128 +#define bid_strtod64 __bid_strtod64 +#define bid_strtod32 __bid_strtod32 +#define bid_wcstod128 __bid_wcstod128 +#define bid_wcstod64 __bid_wcstod64 +#define bid_wcstod32 __bid_wcstod32 + +/////////////////////////////////////////////////////////////// +#ifdef IN_LIBGCC2 +#if !defined ENABLE_DECIMAL_BID_FORMAT || !ENABLE_DECIMAL_BID_FORMAT +#error BID not enabled in libbid +#endif + +#ifndef BID_BIG_ENDIAN +#define BID_BIG_ENDIAN LIBGCC2_FLOAT_WORDS_BIG_ENDIAN +#endif + +#ifndef BID_THREAD +#if defined(HAVE_CC_TLS) && defined(USE_TLS) +#define BID_THREAD __thread +#endif +#endif + +#define BID__intptr_t_defined +#define DECIMAL_CALL_BY_REFERENCE 0 +#define DECIMAL_GLOBAL_ROUNDING 1 +#define DECIMAL_GLOBAL_ROUNDING_ACCESS_FUNCTIONS 1 +#define DECIMAL_GLOBAL_EXCEPTION_FLAGS 1 +#define DECIMAL_GLOBAL_EXCEPTION_FLAGS_ACCESS_FUNCTIONS 1 +#define BID_HAS_GCC_DECIMAL_INTRINSICS 1 +#endif /* IN_LIBGCC2 */ + +// Configuration Options + +#define DECIMAL_TINY_DETECTION_AFTER_ROUNDING 0 +#define BINARY_TINY_DETECTION_AFTER_ROUNDING 1 + +// #define BID_SET_STATUS_FLAGS + +#ifndef BID_THREAD +#if defined(_MSC_VER) // Windows +#define BID_THREAD __declspec(thread) +#else +#if !defined(__APPLE__) // Linux, FreeBSD +#define BID_THREAD __thread +#else // Mac OSX, TBD +#define BID_THREAD +#endif // Linux or Mac +#endif // Windows +#endif // BID_THREAD + +#ifndef BID_HAS_GCC_DECIMAL_INTRINSICS +#define BID_HAS_GCC_DECIMAL_INTRINSICS 0 +#endif + +// set sizeof (long) here, for bid32_lrint(), bid64_lrint(), bid128_lrint(), +// and for bid32_lround(), bid64_lround(), bid128_lround() +#ifndef BID_SIZE_LONG +#if defined(WINDOWS) +#define BID_SIZE_LONG 4 +#else +#if defined(__x86_64__) || defined(__ia64__) || defined(HPUX_OS_64) +#define BID_SIZE_LONG 8 +#else +#define BID_SIZE_LONG 4 +#endif +#endif +#endif + +#if !defined(WINDOWS) || defined(__INTEL_COMPILER) +// #define UNCHANGED_BINARY_STATUS_FLAGS +#endif +// #define HPUX_OS + +// If DECIMAL_CALL_BY_REFERENCE is defined then numerical arguments and results +// are passed by reference otherwise they are passed by value (except that +// a pointer is always passed to the status flags) + +#ifndef DECIMAL_CALL_BY_REFERENCE +#define DECIMAL_CALL_BY_REFERENCE 0 +#endif + +// If DECIMAL_GLOBAL_ROUNDING is defined then the rounding mode is a global +// variable _IDEC_glbround, otherwise it is passed as a parameter when needed + +#ifndef DECIMAL_GLOBAL_ROUNDING +#define DECIMAL_GLOBAL_ROUNDING 0 +#endif + +#ifndef DECIMAL_GLOBAL_ROUNDING_ACCESS_FUNCTIONS +#define DECIMAL_GLOBAL_ROUNDING_ACCESS_FUNCTIONS 0 +#endif + +// If DECIMAL_GLOBAL_EXCEPTION_FLAGS is defined then the exception status flags +// are represented by a global variable _IDEC_glbflags, otherwise they are +// passed as a parameter when needed + +#ifndef DECIMAL_GLOBAL_EXCEPTION_FLAGS +#define DECIMAL_GLOBAL_EXCEPTION_FLAGS 0 +#endif + +#ifndef DECIMAL_GLOBAL_EXCEPTION_FLAGS_ACCESS_FUNCTIONS +#define DECIMAL_GLOBAL_EXCEPTION_FLAGS_ACCESS_FUNCTIONS 0 +#endif + +// If DECIMAL_ALTERNATE_EXCEPTION_HANDLING is defined then the exception masks +// are examined and exception handling information is provided to the caller +// if alternate exception handling is necessary + +#ifndef DECIMAL_ALTERNATE_EXCEPTION_HANDLING +#define DECIMAL_ALTERNATE_EXCEPTION_HANDLING 0 +#endif + +typedef unsigned int _IDEC_round; +typedef unsigned int _IDEC_flags; // could be a struct with diagnostic info + +#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING + // If DECIMAL_GLOBAL_EXCEPTION_MASKS is defined then the exception mask bits + // are represented by a global variable _IDEC_exceptionmasks, otherwise they + // are passed as a parameter when needed; DECIMAL_GLOBAL_EXCEPTION_MASKS is + // ignored + // if DECIMAL_ALTERNATE_EXCEPTION_HANDLING is not defined + // ************************************************************************** +#define DECIMAL_GLOBAL_EXCEPTION_MASKS 0 + // ************************************************************************** + +// If DECIMAL_GLOBAL_EXCEPTION_INFO is defined then the alternate exception +// handling information is represented by a global data structure +// _IDEC_glbexcepthandling, otherwise it is passed by reference as a +// parameter when needed; DECIMAL_GLOBAL_EXCEPTION_INFO is ignored +// if DECIMAL_ALTERNATE_EXCEPTION_HANDLING is not defined +// ************************************************************************** +#define DECIMAL_GLOBAL_EXCEPTION_INFO 0 + // ************************************************************************** +#endif + +// Notes: 1) rnd_mode from _RND_MODE_ARG is used by the caller of a function +// from this library, and can be any name +// 2) rnd_mode and prnd_mode from _RND_MODE_PARAM are fixed names +// and *must* be used in the library functions +// 3) _IDEC_glbround is the fixed name for the global variable holding +// the rounding mode + +#if !DECIMAL_GLOBAL_ROUNDING +#if DECIMAL_CALL_BY_REFERENCE +#define _RND_MODE_ARG , &rnd_mode +#define _RND_MODE_PARAM , _IDEC_round *prnd_mode +#define _RND_MODE_PARAM_0 _IDEC_round *prnd_mode +#define _RND_MODE_ARG_ALONE &rnd_mode +#define _RND_MODE_PARAM_ALONE _IDEC_round *prnd_mode +#else +#define _RND_MODE_ARG , rnd_mode +#define _RND_MODE_PARAM , _IDEC_round rnd_mode +#define _RND_MODE_PARAM_0 _IDEC_round rnd_mode +#define _RND_MODE_ARG_ALONE rnd_mode +#define _RND_MODE_PARAM_ALONE _IDEC_round rnd_mode +#endif +#else +#define _RND_MODE_ARG +#define _RND_MODE_PARAM +#define _RND_MODE_ARG_ALONE +#define _RND_MODE_PARAM_ALONE +#define rnd_mode _IDEC_glbround +#endif + +// Notes: 1) pfpsf from _EXC_FLAGS_ARG is used by the caller of a function +// from this library, and can be any name +// 2) pfpsf from _EXC_FLAGS_PARAM is a fixed name and *must* be used +// in the library functions +// 3) _IDEC_glbflags is the fixed name for the global variable holding +// the floating-point status flags +#if !DECIMAL_GLOBAL_EXCEPTION_FLAGS +#define _EXC_FLAGS_ARG , pfpsf +#define _EXC_FLAGS_PARAM , _IDEC_flags *pfpsf +#else +#define _EXC_FLAGS_ARG +#define _EXC_FLAGS_PARAM +#define pfpsf &_IDEC_glbflags +#endif + +#if DECIMAL_GLOBAL_ROUNDING +BID_EXTERN_C BID_THREAD _IDEC_round _IDEC_glbround; +#endif + +#if DECIMAL_GLOBAL_EXCEPTION_FLAGS +BID_EXTERN_C BID_THREAD _IDEC_flags _IDEC_glbflags; +#endif + +#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING +#if DECIMAL_GLOBAL_EXCEPTION_MASKS +BID_EXTERN_C BID_THREAD _IDEC_exceptionmasks _IDEC_glbexceptionmasks; +#endif +#if DECIMAL_GLOBAL_EXCEPTION_INFO +BID_EXTERN_C BID_THREAD _IDEC_excepthandling _IDEC_glbexcepthandling; +#endif +#endif + +#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING + +// Notes: 1) exc_mask from _EXC_MASKS_ARG is used by the caller of a function +// from this library, and can be any name +// 2) exc_mask and pexc_mask from _EXC_MASKS_PARAM are fixed names +// and *must* be used in the library functions +// 3) _IDEC_glbexceptionmasks is the fixed name for the global +// variable holding the floating-point exception masks +#if !DECIMAL_GLOBAL_EXCEPTION_MASKS +#if DECIMAL_CALL_BY_REFERENCE +#define _EXC_MASKS_ARG , &exc_mask +#define _EXC_MASKS_PARAM , _IDEC_exceptionmasks *pexc_mask +#else +#define _EXC_MASKS_ARG , exc_mask +#define _EXC_MASKS_PARAM , _IDEC_exceptionmasks exc_mask +#endif +#else +#define _EXC_MASKS_ARG +#define _EXC_MASKS_PARAM +#define exc_mask _IDEC_glbexceptionmasks +#endif + +// Notes: 1) BID_pexc_info from _EXC_INFO_ARG is used by the caller of a function +// from this library, and can be any name +// 2) BID_pexc_info from _EXC_INFO_PARAM is a fixed name and *must* be +// used in the library functions +// 3) _IDEC_glbexcepthandling is the fixed name for the global +// variable holding the floating-point exception information +#if !DECIMAL_GLOBAL_EXCEPTION_INFO +#define _EXC_INFO_ARG , BID_pexc_info +#define _EXC_INFO_PARAM , _IDEC_excepthandling *BID_pexc_info +#else +#define _EXC_INFO_ARG +#define _EXC_INFO_PARAM +#define BID_pexc_info &_IDEC_glbexcepthandling +#endif +#else +#define _EXC_MASKS_ARG +#define _EXC_MASKS_PARAM +#define _EXC_INFO_ARG +#define _EXC_INFO_PARAM +#endif + +#ifndef BID_BIG_ENDIAN +#define BID_BIG_ENDIAN 0 +#endif + +#if BID_BIG_ENDIAN +#define BID_SWAP128(x) \ + { \ + BID_UINT64 sw; \ + sw = (x).w[1]; \ + (x).w[1] = (x).w[0]; \ + (x).w[0] = sw; \ + } +#else +#define BID_SWAP128(x) +#endif + +#if DECIMAL_CALL_BY_REFERENCE +#define BID_RETURN_VAL(x) \ + { \ + BID_OPT_RESTORE_BINARY_FLAGS() *pres = (x); \ + return; \ + } +#if BID_BIG_ENDIAN && defined BID_128RES +#define BID_RETURN(x) \ + { \ + BID_OPT_RESTORE_BINARY_FLAGS() \ + BID_SWAP128(x); \ + *pres = (x); \ + return; \ + } +#define BID_RETURN_NOFLAGS(x) \ + { \ + BID_SWAP128(x); \ + *pres = (x); \ + return; \ + } +#else +#define BID_RETURN(x) \ + { \ + BID_OPT_RESTORE_BINARY_FLAGS() *pres = (x); \ + return; \ + } +#define BID_RETURN_NOFLAGS(x) \ + { \ + *pres = (x); \ + return; \ + } +#endif +#else +#define BID_RETURN_VAL(x) \ + { \ + BID_OPT_RESTORE_BINARY_FLAGS() \ + return (x); \ + } +#if BID_BIG_ENDIAN && defined BID_128RES +#define BID_RETURN(x) \ + { \ + BID_OPT_RESTORE_BINARY_FLAGS() \ + BID_SWAP128(x); \ + return (x); \ + } +#define BID_RETURN_NOFLAGS(x) \ + { \ + BID_SWAP128(x); \ + return (x); \ + } +#else +#define BID_RETURN(x) \ + { \ + BID_OPT_RESTORE_BINARY_FLAGS() \ + return (x); \ + } +#define BID_RETURN_NOFLAGS(x) \ + { \ + return (x); \ + } +#endif +#endif + +#if DECIMAL_CALL_BY_REFERENCE +#define BIDECIMAL_CALL1(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), &(_OP1)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), &(_OP1)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2(_FUNC, _RES, _OP1, _OP2) \ + _FUNC(&(_RES), &(_OP1), &(_OP2)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2_YPTR_NORND(_FUNC, _RES, _OP1, _OP2) \ + _FUNC(&(_RES), &(_OP1), &(_OP2)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2_NORND(_FUNC, _RES, _OP1, _OP2) \ + _FUNC(&(_RES), &(_OP1), &(_OP2)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND_RESREF(_FUNC, _RES, _OP1) \ + _FUNC((_RES), &(_OP1)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_RESARG(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), (_OP1)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_RESREF(_FUNC, _RES, _OP1) \ + _FUNC((_RES), &(_OP1)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND_NOSTAT(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), &(_OP1)_EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2_NORND_NOSTAT(_FUNC, _RES, _OP1, _OP2) \ + _FUNC(&(_RES), &(_OP1), &(_OP2)_EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL3(_FUNC, _RES, _OP1, _OP2, _OP3) \ + _FUNC(&(_RES), &(_OP1), &(_OP2), &(_OP3)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), &(_OP1)_EXC_FLAGS_ARG) +#define BIDECIMAL_CALL1_NORND_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), &(_OP1)) +#define BIDECIMAL_CALL1_NORND_NOFLAGS_NOMASK_NOINFO_ARGREF(_FUNC, _RES, _OP1) \ + _FUNC(&(_RES), (_OP1)) +#define BIDECIMAL_CALL2_NORND_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1, _OP2) \ + _FUNC(&(_RES), &(_OP1), &(_OP2)) +#define BIDECIMAL_CALL2_NORND_NOFLAGS_NOMASK_NOINFO_ARG2REF(_FUNC, _RES, _OP1, _OP2) \ + _FUNC(&(_RES), &(_OP1), (_OP2)) +#define BIDECIMAL_CALL1_NORND_NOMASK_NOINFO_RESVOID(_FUNC, _OP1) \ + _FUNC(&(_OP1)_EXC_FLAGS_ARG) +#define BIDECIMAL_CALL2_NORND_NOMASK_NOINFO_RESVOID(_FUNC, _OP1, _OP2) \ + _FUNC(&(_OP1), &(_OP2)_EXC_FLAGS_ARG) +#define BIDECIMAL_CALLV_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES) \ + _FUNC(&(_RES)_RND_MODE_ARG) +#define BIDECIMAL_CALL1_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _FUNC(&(_OP1)_RND_MODE_ARG) +#define BIDECIMAL_CALLV_EMPTY(_FUNC, _RES) \ + _FUNC(&(_RES)) +#else +#define BIDECIMAL_CALL1(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2(_FUNC, _RES, _OP1, _OP2) \ + _RES = _FUNC((_OP1), (_OP2)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2_YPTR_NORND(_FUNC, _RES, _OP1, _OP2) \ + _RES = _FUNC((_OP1), &(_OP2)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2_NORND(_FUNC, _RES, _OP1, _OP2) \ + _RES = _FUNC((_OP1), (_OP2)_EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND_RESREF(_FUNC, _RES, _OP1) \ + _FUNC((_RES), _OP1 _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_RESARG(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_RESREF(_FUNC, _RES, _OP1) \ + _FUNC((_RES), _OP1 _RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND_NOSTAT(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)_EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL2_NORND_NOSTAT(_FUNC, _RES, _OP1, _OP2) \ + _RES = _FUNC((_OP1), (_OP2)_EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL3(_FUNC, _RES, _OP1, _OP2, _OP3) \ + _RES = _FUNC((_OP1), (_OP2), (_OP3)_RND_MODE_ARG _EXC_FLAGS_ARG _EXC_MASKS_ARG _EXC_INFO_ARG) +#define BIDECIMAL_CALL1_NORND_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)_EXC_FLAGS_ARG) +#define BIDECIMAL_CALL1_NORND_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)) +#define BIDECIMAL_CALL1_NORND_NOFLAGS_NOMASK_NOINFO_ARGREF(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)) +#define BIDECIMAL_CALL2_NORND_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1, _OP2) \ + _RES = _FUNC((_OP1), (_OP2)) +#define BIDECIMAL_CALL2_NORND_NOFLAGS_NOMASK_NOINFO_ARG2REF(_FUNC, _RES, _OP1, _OP2) \ + _RES = _FUNC((_OP1), (_OP2)) +#define BIDECIMAL_CALL1_NORND_NOMASK_NOINFO_RESVOID(_FUNC, _OP1) \ + _FUNC((_OP1)_EXC_FLAGS_ARG) +#define BIDECIMAL_CALL2_NORND_NOMASK_NOINFO_RESVOID(_FUNC, _OP1, _OP2) \ + _FUNC((_OP1), (_OP2)_EXC_FLAGS_ARG) +#define BIDECIMAL_CALLV_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES) \ + _RES = _FUNC(_RND_MODE_ARG_ALONE) +#if !DECIMAL_GLOBAL_ROUNDING +#define BIDECIMAL_CALL1_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _RES = _FUNC((_OP1)_RND_MODE_ARG) +#else +#define BIDECIMAL_CALL1_NOFLAGS_NOMASK_NOINFO(_FUNC, _RES, _OP1) \ + _FUNC((_OP1)_RND_MODE_ARG) +#endif +#define BIDECIMAL_CALLV_EMPTY(_FUNC, _RES) \ + _RES = _FUNC() +#endif + +/////////////////////////////////////////////////////////////////////////// +// +// Wrapper macros for ICL +// +/////////////////////////////////////////////////////////////////////////// + +#if defined(__INTEL_COMPILER) && (__DFP_WRAPPERS_ON) && (!DECIMAL_CALL_BY_REFERENCE) && (DECIMAL_GLOBAL_ROUNDING) && (DECIMAL_GLOBAL_EXCEPTION_FLAGS) + +#include "bid_wrap_names.h" + +#define DECLSPEC_OPT __declspec(noinline) + +#define bit_size_BID_UINT128 128 +#define bit_size_BID_UINT64 64 +#define bit_size_BID_SINT64 64 +#define bit_size_BID_UINT32 32 +#define bit_size_BID_SINT32 32 + +#define bidsize(x) bit_size_##x + +#define form_type(type, size) type##size + +#define wrapper_name(x) __wrap_##x + +#define DFP_WRAPFN_OTHERTYPE(rsize, fn_name, othertype) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(othertype __wraparg1) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + r.i = fn_name(__wraparg1); \ + return r.d; \ + } + +#define DFP_WRAPFN_DFP(rsize, fn_name, isize1) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + r.i = fn_name(in1.i); \ + \ + return r.d; \ + } + +#define DFP_WRAPFN_DFP_DFP(rsize, fn_name, isize1, isize2) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1, form_type(_Decimal, isize2) __wraparg2) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + union { \ + form_type(_Decimal, isize2) d; \ + form_type(BID_UINT, isize2) i; \ + } in2 = {__wraparg2}; \ + \ + r.i = fn_name(in1.i, in2.i); \ + \ + return r.d; \ + } + +#define DFP_WRAPFN_DFP_DFP_POINTER(rsize, fn_name, isize1, isize2) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1, form_type(_Decimal, isize2) * __wraparg2) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + union { \ + form_type(_Decimal, isize2) d; \ + form_type(BID_UINT, isize2) i; \ + } out2; \ + \ + r.i = fn_name(in1.i, &out2.i); \ + *__wraparg2 = out2.d; \ + \ + return r.d; \ + } + +#define DFP_WRAPFN_DFP_DFP_DFP(rsize, fn_name, isize1, isize2, isize3) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1, form_type(_Decimal, isize2) __wraparg2, form_type(_Decimal, isize3) __wraparg3) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + union { \ + form_type(_Decimal, isize2) d; \ + form_type(BID_UINT, isize2) i; \ + } in2 = {__wraparg2}; \ + \ + union { \ + form_type(_Decimal, isize3) d; \ + form_type(BID_UINT, isize3) i; \ + } in3 = {__wraparg3}; \ + \ + r.i = fn_name(in1.i, in2.i, in3.i); \ + \ + return r.d; \ + } + +#define RES_WRAPFN_DFP(restype, fn_name, isize1) \ + restype wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1) { \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + return fn_name(in1.i); \ + } + +#define RES_WRAPFN_DFP_DFP(restype, fn_name, isize1, isize2) \ + restype wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1, form_type(_Decimal, isize2) __wraparg2) { \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + union { \ + form_type(_Decimal, isize2) d; \ + form_type(BID_UINT, isize2) i; \ + } in2 = {__wraparg2}; \ + \ + return fn_name(in1.i, in2.i); \ + } + +#define DFP_WRAPFN_DFP_OTHERTYPE(rsize, fn_name, isize1, othertype) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(form_type(_Decimal, isize1) __wraparg1, othertype __wraparg2) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + r.i = fn_name(in1.i, __wraparg2); \ + \ + return r.d; \ + } + +#define VOID_WRAPFN_OTHERTYPERES_DFP(fn_name, othertype, isize1) \ + void wrapper_name(fn_name)(othertype * __wrapres, form_type(_Decimal, isize1) __wraparg1) { \ + union { \ + form_type(_Decimal, isize1) d; \ + form_type(BID_UINT, isize1) i; \ + } in1 = {__wraparg1}; \ + \ + fn_name(__wrapres, in1.i); \ + } + +#define DFP_WRAPFN_TYPE1_TYPE2(rsize, fn_name, type1, type2) \ + form_type(_Decimal, rsize) wrapper_name(fn_name)(type1 __wraparg1, type2 __wraparg2) { \ + union { \ + form_type(_Decimal, rsize) d; \ + form_type(BID_UINT, rsize) i; \ + } r; \ + \ + r.i = fn_name(__wraparg1, __wraparg2); \ + \ + return r.d; \ + } + +#else + +#define DECLSPEC_OPT + +#define DFP_WRAPFN_OTHERTYPE(rsize, fn_name, othertype) +#define DFP_WRAPFN_DFP(rsize, fn_name, isize1) +#define DFP_WRAPFN_DFP_DFP(rsize, fn_name, isize1, isize2) +#define RES_WRAPFN_DFP(rsize, fn_name, isize1) +#define RES_WRAPFN_DFP_DFP(rsize, fn_name, isize1, isize2) +#define DFP_WRAPFN_DFP_DFP_DFP(rsize, fn_name, isize1, isize2, isize3) +#define DFP_WRAPFN_DFP_OTHERTYPE(rsize, fn_name, isize1, othertype) +#define DFP_WRAPFN_DFP_DFP_POINTER(rsize, fn_name, isize1, isize2) +#define VOID_WRAPFN_OTHERTYPERES_DFP(fn_name, othertype, isize1) +#define DFP_WRAPFN_TYPE1_TYPE2(rsize, fn_name, type1, type2) + +#endif + +/////////////////////////////////////////////////////////////////////////// + +#if BID_BIG_ENDIAN +#define BID_HIGH_128W 0 +#define BID_LOW_128W 1 +#else +#define BID_HIGH_128W 1 +#define BID_LOW_128W 0 +#endif + +#if (BID_BIG_ENDIAN) && defined(BID_128RES) +#define BID_COPY_ARG_REF(arg_name) \ + BID_UINT128 arg_name = {{pbid_##arg_name->w[1], pbid_##arg_name->w[0]}}; +#define BID_COPY_ARG_VAL(arg_name) \ + BID_UINT128 arg_name = {{bid_##arg_name.w[1], bid_##arg_name.w[0]}}; +#else +#define BID_COPY_ARG_REF(arg_name) \ + BID_UINT128 arg_name = *pbid_##arg_name; +#define BID_COPY_ARG_VAL(arg_name) \ + BID_UINT128 arg_name = bid_##arg_name; +#endif + +#define BID_COPY_ARG_TYPE_REF(type, arg_name) \ + type arg_name = *pbid_##arg_name; +#define BID_COPY_ARG_TYPE_VAL(type, arg_name) \ + type arg_name = bid_##arg_name; + +#if !DECIMAL_GLOBAL_ROUNDING +#define BID_SET_RND_MODE() \ + _IDEC_round rnd_mode = *prnd_mode; +#else +#define BID_SET_RND_MODE() +#endif + +#if !defined(BID_MS_FLAGS) && (defined(_MSC_VER) && !defined(__INTEL_COMPILER)) +#define BID_MS_FLAGS +#endif + +#if (defined(_MSC_VER) && !defined(__INTEL_COMPILER)) +#include // needed for MS build of some BID32 transcendentals (hypot) +#endif + +#if defined(UNCHANGED_BINARY_STATUS_FLAGS) && defined(BID_FUNCTION_SETS_BINARY_FLAGS) +#if defined(BID_MS_FLAGS) + +#include + +extern unsigned int __bid_ms_restore_flags(unsigned int *); + +#define BID_OPT_FLAG_DECLARE() \ + unsigned int binaryflags = 0; +#define BID_OPT_SAVE_BINARY_FLAGS() \ + binaryflags = _statusfp(); +#define BID_OPT_RESTORE_BINARY_FLAGS() \ + __bid_ms_restore_flags(&binaryflags); + +#else +#include +#define BID_FE_ALL_FLAGS FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT +#define BID_OPT_FLAG_DECLARE() \ + fexcept_t binaryflags = 0; +#define BID_OPT_SAVE_BINARY_FLAGS() \ + (void)fegetexceptflag(&binaryflags, BID_FE_ALL_FLAGS); +#define BID_OPT_RESTORE_BINARY_FLAGS() \ + (void)fesetexceptflag(&binaryflags, BID_FE_ALL_FLAGS); +#endif +#else +#define BID_OPT_FLAG_DECLARE() +#define BID_OPT_SAVE_BINARY_FLAGS() +#define BID_OPT_RESTORE_BINARY_FLAGS() +#endif + +#define BID_PROLOG_REF(arg_name) \ + BID_COPY_ARG_REF(arg_name) + +#define BID_PROLOG_VAL(arg_name) \ + BID_COPY_ARG_VAL(arg_name) + +#define BID_PROLOG_TYPE_REF(type, arg_name) \ + BID_COPY_ARG_TYPE_REF(type, arg_name) + +#define BID_PROLOG_TYPE_VAL(type, arg_name) \ + BID_COPY_ARG_TYPE_VAL(type, arg_name) + +#define OTHER_BID_PROLOG_REF() BID_OPT_FLAG_DECLARE() +#define OTHER_BID_PROLOG_VAL() BID_OPT_FLAG_DECLARE() + +#if DECIMAL_CALL_BY_REFERENCE +#define BID128_FUNCTION_ARG1(fn_name, arg_name) \ + void fn_name(BID_UINT128 *pres, \ + BID_UINT128 * \ + pbid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG1_NORND(fn_name, arg_name) \ + void fn_name(BID_UINT128 *pres, \ + BID_UINT128 * \ + pbid_##arg_name _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name) \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG1_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name) \ + void fn_name(restype *pres, \ + BID_UINT128 * \ + pbid_##arg_name _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name) \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG2(fn_name, arg_name1, arg_name2) \ + void fn_name(BID_UINT128 *pres, \ + BID_UINT128 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG2_NORND(fn_name, arg_name1, arg_name2) \ + void fn_name(BID_UINT128 *pres, \ + BID_UINT128 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name1, arg_name2) \ + void fn_name(restype *pres, \ + BID_UINT128 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG2P_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name1, arg_name2) \ + void fn_name(restype *pres, \ + BID_UINT128 *pbid_##arg_name1, BID_UINT128 *arg_name2 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG3P_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name1, arg_name2, res_name3) \ + void fn_name(restype *pres, \ + BID_UINT128 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2, BID_UINT128 *res_name3 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG128_ARGTYPE2(fn_name, arg_name1, type2, arg_name2) \ + void fn_name(BID_UINT128 *pres, \ + BID_UINT128 *pbid_##arg_name1, type2 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_TYPE_REF(type2, arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARG128_CUSTOMARGTYPE2(fn_name, arg_name1, type2, arg_name2) BID128_FUNCTION_ARG128_ARGTYPE2(fn_name, arg_name1, type2, arg_name2) + +#define BID128_FUNCTION_ARG128_CUSTOMARGTYPE2_PLAIN(fn_name, arg_name1, type2, arg_name2) \ + void fn_name(BID_UINT128 *pres, \ + BID_UINT128 *pbid_##arg_name1, type2 arg_name2) { \ + BID_PROLOG_REF(arg_name1) \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2(type0, fn_name, type1, arg_name1, type2, arg_name2) \ + void fn_name(type0 *pres, \ + type1 *pbid_##arg_name1, type2 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name1) \ + BID_PROLOG_TYPE_REF(type2, arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARGTYPE1_OTHER_ARGTYPE2 BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2 + +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2_ARGTYPE3(type0, fn_name, type1, arg_name1, type2, arg_name2, type3, arg_name3) \ + void fn_name(type0 *pres, \ + type1 *pbid_##arg_name1, type2 *pbid_##arg_name2, type3 *pbid_##arg_name3 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name1) \ + BID_PROLOG_TYPE_REF(type2, arg_name2) \ + BID_PROLOG_TYPE_REF(type3, arg_name3) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE_FUNCTION_ARG2(type0, fn_name, arg_name1, arg_name2) \ + void fn_name(type0 *pres, \ + type0 *pbid_##arg_name1, type0 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type0, arg_name1) \ + BID_PROLOG_TYPE_REF(type0, arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE_FUNCTION_ARG2_CUSTOMRESULT_NORND(typeres, fn_name, type0, arg_name1, arg_name2) \ + void fn_name(typeres *pres, \ + type0 *pbid_##arg_name1, type0 *pbid_##arg_name2 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type0, arg_name1) \ + BID_PROLOG_TYPE_REF(type0, arg_name2) \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE_FUNCTION_ARG1(type0, fn_name, arg_name1) \ + void fn_name(type0 *pres, \ + type0 *pbid_##arg_name1 \ + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type0, arg_name1) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARGTYPE1_ARG128(fn_name, type1, arg_name1, arg_name2) \ + void fn_name(BID_UINT128 *pres, \ + type1 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARG128_ARGTYPE2(type0, fn_name, arg_name1, type2, arg_name2) \ + void fn_name(type0 *pres, \ + BID_UINT128 *pbid_##arg_name1, type2 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_TYPE_REF(type2, arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARG128(type0, fn_name, type1, arg_name1, arg_name2) \ + void fn_name(type0 *pres, \ + type1 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARG128_ARG128(type0, fn_name, arg_name1, arg_name2) \ + void fn_name(type0 *pres, \ + BID_UINT128 *pbid_##arg_name1, BID_UINT128 *pbid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name1) \ + BID_PROLOG_REF(arg_name2) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARG1(type0, fn_name, arg_name) \ + void fn_name(type0 *pres, \ + BID_UINT128 * \ + pbid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_REF(arg_name) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID128_FUNCTION_ARGTYPE1(fn_name, type1, arg_name) \ + void fn_name(BID_UINT128 *pres, \ + type1 * \ + pbid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARGTYPE1(type0, fn_name, type1, arg_name) \ + void fn_name(type0 *pres, \ + type1 * \ + pbid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name) \ + BID_SET_RND_MODE() \ + OTHER_BID_PROLOG_REF() + +#define BID_RESTYPE0_FUNCTION_ARGTYPE1 BID_TYPE0_FUNCTION_ARGTYPE1 + +#define BID_TYPE0_FUNCTION_ARGTYPE1_NORND(type0, fn_name, type1, arg_name) \ + void fn_name(type0 *pres, \ + type1 * \ + pbid_##arg_name _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name) \ + OTHER_BID_PROLOG_REF() + +#define BID_TYPE0_FUNCTION_ARGTYPE1_NORND_DFP BID_TYPE0_FUNCTION_ARGTYPE1_NORND + +#define BID_TYPE0_FUNCTION_ARGTYPE1_NORND_NOFLAGS(type0, fn_name, type1, arg_name) \ + void fn_name(type0 *pres, \ + type1 * \ + pbid_##arg_name _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name) + +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2_NORND(type0, fn_name, type1, arg_name1, type2, arg_name2) \ + void fn_name(type0 *pres, \ + type1 * \ + pbid_##arg_name1, \ + type2 *pbid_##arg_name2 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM \ + _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_REF(type1, arg_name1) \ + BID_PROLOG_TYPE_REF(type2, arg_name2) \ + OTHER_BID_PROLOG_REF() +////////////////////////////////////////// +///////////////////////////////////////// +//////////////////////////////////////// + +#else + +////////////////////////////////////////// +///////////////////////////////////////// +//////////////////////////////////////// + +// BID args and result +#define BID128_FUNCTION_ARG1(fn_name, arg_name) \ + DFP_WRAPFN_DFP(128, fn_name, 128); \ + \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID128_FUNCTION_ARG1_NORND(fn_name, arg_name) \ + DFP_WRAPFN_DFP(128, fn_name, 128); \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name) \ + OTHER_BID_PROLOG_VAL() + +// result is not BID type +#define BID128_FUNCTION_ARG1_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name) \ + RES_WRAPFN_DFP(restype, fn_name, 128); \ + DECLSPEC_OPT restype \ + fn_name(BID_UINT128 bid_##arg_name _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID128_FUNCTION_ARG2(fn_name, arg_name1, arg_name2) \ + DFP_WRAPFN_DFP_DFP(128, fn_name, 128, 128); \ + \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// fmod, rem +#define BID128_FUNCTION_ARG2_NORND(fn_name, arg_name1, arg_name2) \ + DFP_WRAPFN_DFP_DFP(128, fn_name, 128, 128); \ + \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2 _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// compares +#define BID128_FUNCTION_ARG2_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name1, arg_name2) \ + RES_WRAPFN_DFP_DFP(restype, fn_name, 128, 128); \ + DECLSPEC_OPT restype \ + fn_name(BID_UINT128 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2 _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// not currently used +#define BID128_FUNCTION_ARG2P_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name1, res_name2) \ + RES_WRAPFN_DFP_DFP(restype, fn_name, 128, 128); \ + DECLSPEC_OPT restype \ + fn_name(BID_UINT128 bid_##arg_name1, \ + BID_UINT128 *res_name2 _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + OTHER_BID_PROLOG_VAL() + +// not currently used +#define BID128_FUNCTION_ARG3P_NORND_CUSTOMRESTYPE(restype, fn_name, arg_name1, arg_name2, res_name3) \ + RES_WRAPFN_DFP_DFP_DFP(restype, fn_name, 128, 128, 128); \ + DECLSPEC_OPT restype \ + fn_name(BID_UINT128 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2, BID_UINT128 *res_name3 _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID128_FUNCTION_ARG128_ARGTYPE2(fn_name, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_DFP(128, fn_name, 128, bidsize(type2)); \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + type2 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// scalb, ldexp +#define BID128_FUNCTION_ARG128_CUSTOMARGTYPE2(fn_name, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_OTHERTYPE(128, fn_name, 128, type2); \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + type2 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// frexp +#define BID128_FUNCTION_ARG128_CUSTOMARGTYPE2_PLAIN(fn_name, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_OTHERTYPE(128, fn_name, 128, type2); \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + type2 arg_name2) { \ + BID_PROLOG_VAL(arg_name1) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2(type0, fn_name, type1, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_DFP(bidsize(type0), fn_name, bidsize(type1), bidsize(type2)); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name1, \ + type2 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID arg1 and result +#define BID_TYPE0_FUNCTION_ARGTYPE1_OTHER_ARGTYPE2(type0, fn_name, type1, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_OTHERTYPE(bidsize(type0), fn_name, bidsize(type1), type2); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name1, \ + type2 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2_ARGTYPE3(type0, fn_name, type1, arg_name1, type2, arg_name2, type3, arg_name3) \ + DFP_WRAPFN_DFP_DFP_DFP(bidsize(type0), fn_name, bidsize(type1), bidsize(type2), bidsize(type3)); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name1, \ + type2 bid_##arg_name2, type3 bid_##arg_name3 _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + BID_PROLOG_TYPE_VAL(type3, arg_name3) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE_FUNCTION_ARG2(type0, fn_name, arg_name1, arg_name2) \ + DFP_WRAPFN_DFP_DFP(bidsize(type0), fn_name, bidsize(type0), bidsize(type0)); \ + DECLSPEC_OPT type0 \ + fn_name(type0 bid_##arg_name1, \ + type0 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type0, arg_name1) \ + BID_PROLOG_TYPE_VAL(type0, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args, result a different type (e.g. for compares) +#define BID_TYPE_FUNCTION_ARG2_CUSTOMRESULT_NORND(typeres, fn_name, type0, arg_name1, arg_name2) \ + RES_WRAPFN_DFP_DFP(typeres, fn_name, bidsize(type0), bidsize(type0)); \ + DECLSPEC_OPT typeres \ + fn_name(type0 bid_##arg_name1, \ + type0 bid_##arg_name2 _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type0, arg_name1) \ + BID_PROLOG_TYPE_VAL(type0, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE_FUNCTION_ARG1(type0, fn_name, arg_name1) \ + DFP_WRAPFN_DFP(bidsize(type0), fn_name, bidsize(type0)); \ + DECLSPEC_OPT type0 \ + fn_name(type0 bid_##arg_name1 \ + _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type0, arg_name1) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID128_FUNCTION_ARGTYPE1_ARG128(fn_name, type1, arg_name1, arg_name2) \ + DFP_WRAPFN_DFP_DFP(128, fn_name, bidsize(type1), 128); \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(type1 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARG128_ARGTYPE2(type0, fn_name, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_DFP(bidsize(type0), fn_name, 128, bidsize(type2)); \ + DECLSPEC_OPT type0 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + type2 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARG128(type0, fn_name, type1, arg_name1, arg_name2) \ + DFP_WRAPFN_DFP_DFP(bidsize(type0), fn_name, bidsize(type1), 128); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARG128_ARG128(type0, fn_name, arg_name1, arg_name2) \ + DFP_WRAPFN_DFP_DFP(bidsize(type0), fn_name, 128, 128); \ + DECLSPEC_OPT type0 \ + fn_name(BID_UINT128 bid_##arg_name1, \ + BID_UINT128 bid_##arg_name2 _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name1) \ + BID_PROLOG_VAL(arg_name2) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARG1(type0, fn_name, arg_name) \ + DFP_WRAPFN_DFP(bidsize(type0), fn_name, 128); \ + DECLSPEC_OPT type0 \ + fn_name(BID_UINT128 bid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_VAL(arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID128_FUNCTION_ARGTYPE1(fn_name, type1, arg_name) \ + DFP_WRAPFN_DFP(128, fn_name, bidsize(type1)); \ + DECLSPEC_OPT BID_UINT128 \ + fn_name(type1 bid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARGTYPE1(type0, fn_name, type1, arg_name) \ + DFP_WRAPFN_DFP(bidsize(type0), fn_name, bidsize(type1)) \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID args and result +#define BID_TYPE0_FUNCTION_ARGTYPE1_NORND_DFP(type0, fn_name, type1, arg_name) \ + DFP_WRAPFN_DFP(bidsize(type0), fn_name, bidsize(type1)) \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID args, different type result +#define BID_RESTYPE0_FUNCTION_ARGTYPE1(type0, fn_name, type1, arg_name) \ + RES_WRAPFN_DFP(type0, fn_name, bidsize(type1)) \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name _RND_MODE_PARAM _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name) \ + OTHER_BID_PROLOG_VAL() + +// BID to int/uint functions +#define BID_TYPE0_FUNCTION_ARGTYPE1_NORND(type0, fn_name, type1, arg_name) \ + RES_WRAPFN_DFP(type0, fn_name, bidsize(type1)); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name) \ + OTHER_BID_PROLOG_VAL() + +// used for BID-to-BID conversions +#define BID_TYPE0_FUNCTION_ARGTYPE1_NORND_NOFLAGS(type0, fn_name, type1, arg_name) \ + DFP_WRAPFN_DFP(bidsize(type0), fn_name, bidsize(type1)); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name) + +// fmod, rem +#define BID_TYPE0_FUNCTION_ARGTYPE1_ARGTYPE2_NORND(type0, fn_name, type1, arg_name1, type2, arg_name2) \ + DFP_WRAPFN_DFP_DFP(bidsize(type0), fn_name, bidsize(type1), bidsize(type2)); \ + DECLSPEC_OPT type0 \ + fn_name(type1 bid_##arg_name1, type2 bid_##arg_name2 _EXC_FLAGS_PARAM \ + _EXC_MASKS_PARAM _EXC_INFO_PARAM) { \ + BID_PROLOG_TYPE_VAL(type1, arg_name1) \ + BID_PROLOG_TYPE_VAL(type2, arg_name2) \ + OTHER_BID_PROLOG_VAL() +#endif + +#define BID_TO_SMALL_BID_UINT_CVT_FUNCTION(type0, fn_name, type1, arg_name, cvt_fn_name, type2, size_mask, invalid_res) \ + BID_TYPE0_FUNCTION_ARGTYPE1_NORND(type0, fn_name, type1, arg_name) \ + type2 res; \ + _IDEC_flags saved_fpsc = *pfpsf; \ + BIDECIMAL_CALL1_NORND(cvt_fn_name, res, arg_name); \ + if (res & size_mask) { \ + *pfpsf = saved_fpsc | BID_INVALID_EXCEPTION; \ + res = invalid_res; \ + } \ + BID_RETURN_VAL((type0)res); \ + } + +#define BID_TO_SMALL_INT_CVT_FUNCTION(type0, fn_name, type1, arg_name, cvt_fn_name, type2, size_mask, invalid_res) \ + BID_TYPE0_FUNCTION_ARGTYPE1_NORND(type0, fn_name, type1, arg_name) \ + type2 res, sgn_mask; \ + _IDEC_flags saved_fpsc = *pfpsf; \ + BIDECIMAL_CALL1_NORND(cvt_fn_name, res, arg_name); \ + sgn_mask = res & size_mask; \ + if (sgn_mask && (sgn_mask != (type2)size_mask)) { \ + *pfpsf = saved_fpsc | BID_INVALID_EXCEPTION; \ + res = invalid_res; \ + } \ + BID_RETURN_VAL((type0)res); \ + } +#endif diff --git a/reftest/bid_decimal_data.c b/reftest/bid_decimal_data.c new file mode 100644 index 0000000..c171ea6 --- /dev/null +++ b/reftest/bid_decimal_data.c @@ -0,0 +1,1325 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 "bid_internal.h" + +BID_UINT64 bid_round_const_table[][19] = { + { // RN + 0ull, // 0 extra digits + 5ull, // 1 extra digits + 50ull, // 2 extra digits + 500ull, // 3 extra digits + 5000ull, // 4 extra digits + 50000ull, // 5 extra digits + 500000ull, // 6 extra digits + 5000000ull, // 7 extra digits + 50000000ull, // 8 extra digits + 500000000ull, // 9 extra digits + 5000000000ull, // 10 extra digits + 50000000000ull, // 11 extra digits + 500000000000ull, // 12 extra digits + 5000000000000ull, // 13 extra digits + 50000000000000ull, // 14 extra digits + 500000000000000ull, // 15 extra digits + 5000000000000000ull, // 16 extra digits + 50000000000000000ull, // 17 extra digits + 500000000000000000ull // 18 extra digits + } + , + { // RD + 0ull, // 0 extra digits + 0ull, // 1 extra digits + 0ull, // 2 extra digits + 00ull, // 3 extra digits + 000ull, // 4 extra digits + 0000ull, // 5 extra digits + 00000ull, // 6 extra digits + 000000ull, // 7 extra digits + 0000000ull, // 8 extra digits + 00000000ull, // 9 extra digits + 000000000ull, // 10 extra digits + 0000000000ull, // 11 extra digits + 00000000000ull, // 12 extra digits + 000000000000ull, // 13 extra digits + 0000000000000ull, // 14 extra digits + 00000000000000ull, // 15 extra digits + 000000000000000ull, // 16 extra digits + 0000000000000000ull, // 17 extra digits + 00000000000000000ull // 18 extra digits + } + , + { // round to Inf + 0ull, // 0 extra digits + 9ull, // 1 extra digits + 99ull, // 2 extra digits + 999ull, // 3 extra digits + 9999ull, // 4 extra digits + 99999ull, // 5 extra digits + 999999ull, // 6 extra digits + 9999999ull, // 7 extra digits + 99999999ull, // 8 extra digits + 999999999ull, // 9 extra digits + 9999999999ull, // 10 extra digits + 99999999999ull, // 11 extra digits + 999999999999ull, // 12 extra digits + 9999999999999ull, // 13 extra digits + 99999999999999ull, // 14 extra digits + 999999999999999ull, // 15 extra digits + 9999999999999999ull, // 16 extra digits + 99999999999999999ull, // 17 extra digits + 999999999999999999ull // 18 extra digits + } + , + { // RZ + 0ull, // 0 extra digits + 0ull, // 1 extra digits + 0ull, // 2 extra digits + 00ull, // 3 extra digits + 000ull, // 4 extra digits + 0000ull, // 5 extra digits + 00000ull, // 6 extra digits + 000000ull, // 7 extra digits + 0000000ull, // 8 extra digits + 00000000ull, // 9 extra digits + 000000000ull, // 10 extra digits + 0000000000ull, // 11 extra digits + 00000000000ull, // 12 extra digits + 000000000000ull, // 13 extra digits + 0000000000000ull, // 14 extra digits + 00000000000000ull, // 15 extra digits + 000000000000000ull, // 16 extra digits + 0000000000000000ull, // 17 extra digits + 00000000000000000ull // 18 extra digits + } + , + { // round ties away from 0 + 0ull, // 0 extra digits + 5ull, // 1 extra digits + 50ull, // 2 extra digits + 500ull, // 3 extra digits + 5000ull, // 4 extra digits + 50000ull, // 5 extra digits + 500000ull, // 6 extra digits + 5000000ull, // 7 extra digits + 50000000ull, // 8 extra digits + 500000000ull, // 9 extra digits + 5000000000ull, // 10 extra digits + 50000000000ull, // 11 extra digits + 500000000000ull, // 12 extra digits + 5000000000000ull, // 13 extra digits + 50000000000000ull, // 14 extra digits + 500000000000000ull, // 15 extra digits + 5000000000000000ull, // 16 extra digits + 50000000000000000ull, // 17 extra digits + 500000000000000000ull // 18 extra digits + } + , +}; + +BID_UINT128 bid_round_const_table_128[][36] = { + { //RN + {{0ull, 0ull} + } + , // 0 extra digits + {{5ull, 0ull} + } + , // 1 extra digits + {{50ull, 0ull} + } + , // 2 extra digits + {{500ull, 0ull} + } + , // 3 extra digits + {{5000ull, 0ull} + } + , // 4 extra digits + {{50000ull, 0ull} + } + , // 5 extra digits + {{500000ull, 0ull} + } + , // 6 extra digits + {{5000000ull, 0ull} + } + , // 7 extra digits + {{50000000ull, 0ull} + } + , // 8 extra digits + {{500000000ull, 0ull} + } + , // 9 extra digits + {{5000000000ull, 0ull} + } + , // 10 extra digits + {{50000000000ull, 0ull} + } + , // 11 extra digits + {{500000000000ull, 0ull} + } + , // 12 extra digits + {{5000000000000ull, 0ull} + } + , // 13 extra digits + {{50000000000000ull, 0ull} + } + , // 14 extra digits + {{500000000000000ull, 0ull} + } + , // 15 extra digits + {{5000000000000000ull, 0ull} + } + , // 16 extra digits + {{50000000000000000ull, 0ull} + } + , // 17 extra digits + {{500000000000000000ull, 0ull} + } + , // 18 extra digits + {{5000000000000000000ull, 0ull} + } + , // 19 extra digits + {{0xb5e3af16b1880000ull, 2ull} + } + , //20 + {{0x1ae4d6e2ef500000ull, 27ull} + } + , //21 + {{0xcf064dd59200000ull, 271ull} + } + , //22 + {{0x8163f0a57b400000ull, 2710ull} + } + , //23 + {{0xde76676d0800000ull, 27105ull} + } + , //24 + {{0x8b0a00a425000000ull, 0x422caull} + } + , //25 + {{0x6e64066972000000ull, 0x295be9ull} + } + , //26 + {{0x4fe8401e74000000ull, 0x19d971eull} + } + , //27 + {{0x1f12813088000000ull, 0x1027e72full} + } + , //28 + {{0x36b90be550000000ull, 0xa18f07d7ull} + } + , //29 + {{0x233a76f520000000ull, 0x64f964e68ull} + } + , //30 + {{0x6048a59340000000ull, 0x3f1bdf1011ull} + } + , //31 + {{0xc2d677c080000000ull, 0x27716b6a0adull} + } + , //32 + {{0x9c60ad8500000000ull, 0x18a6e32246c9ull} + } + , //33 + {{0x1bc6c73200000000ull, 0xf684df56c3e0ull} + } + , //34 + {{0x15c3c7f400000000ull, 0x9a130b963a6c1ull} + } + , //35 + } + , + { //RD + {{0ull, 0ull} + } + , // 0 extra digits + {{0ull, 0ull} + } + , // 1 extra digits + {{0ull, 0ull} + } + , // 2 extra digits + {{00ull, 0ull} + } + , // 3 extra digits + {{000ull, 0ull} + } + , // 4 extra digits + {{0000ull, 0ull} + } + , // 5 extra digits + {{00000ull, 0ull} + } + , // 6 extra digits + {{000000ull, 0ull} + } + , // 7 extra digits + {{0000000ull, 0ull} + } + , // 8 extra digits + {{00000000ull, 0ull} + } + , // 9 extra digits + {{000000000ull, 0ull} + } + , // 10 extra digits + {{0000000000ull, 0ull} + } + , // 11 extra digits + {{00000000000ull, 0ull} + } + , // 12 extra digits + {{000000000000ull, 0ull} + } + , // 13 extra digits + {{0000000000000ull, 0ull} + } + , // 14 extra digits + {{00000000000000ull, 0ull} + } + , // 15 extra digits + {{000000000000000ull, 0ull} + } + , // 16 extra digits + {{0000000000000000ull, 0ull} + } + , // 17 extra digits + {{00000000000000000ull, 0ull} + } + , // 18 extra digits + {{000000000000000000ull, 0ull} + } + , // 19 extra digits + {{0ull, 0ull} + } + , //20 + {{0ull, 0ull} + } + , //21 + {{0ull, 0ull} + } + , //22 + {{0ull, 0ull} + } + , //23 + {{0ull, 0ull} + } + , //24 + {{0ull, 0ull} + } + , //25 + {{0ull, 0ull} + } + , //26 + {{0ull, 0ull} + } + , //27 + {{0ull, 0ull} + } + , //28 + {{0ull, 0ull} + } + , //29 + {{0ull, 0ull} + } + , //30 + {{0ull, 0ull} + } + , //31 + {{0ull, 0ull} + } + , //32 + {{0ull, 0ull} + } + , //33 + {{0ull, 0ull} + } + , //34 + {{0ull, 0ull} + } + , //35 + } + , + { //RU + {{0ull, 0ull} + } + , // 0 extra digits + {{9ull, 0ull} + } + , // 1 extra digits + {{99ull, 0ull} + } + , // 2 extra digits + {{999ull, 0ull} + } + , // 3 extra digits + {{9999ull, 0ull} + } + , // 4 extra digits + {{99999ull, 0ull} + } + , // 5 extra digits + {{999999ull, 0ull} + } + , // 6 extra digits + {{9999999ull, 0ull} + } + , // 7 extra digits + {{99999999ull, 0ull} + } + , // 8 extra digits + {{999999999ull, 0ull} + } + , // 9 extra digits + {{9999999999ull, 0ull} + } + , // 10 extra digits + {{99999999999ull, 0ull} + } + , // 11 extra digits + {{999999999999ull, 0ull} + } + , // 12 extra digits + {{9999999999999ull, 0ull} + } + , // 13 extra digits + {{99999999999999ull, 0ull} + } + , // 14 extra digits + {{999999999999999ull, 0ull} + } + , // 15 extra digits + {{9999999999999999ull, 0ull} + } + , // 16 extra digits + {{99999999999999999ull, 0ull} + } + , // 17 extra digits + {{999999999999999999ull, 0ull} + } + , // 18 extra digits + {{9999999999999999999ull, 0ull} + } + , // 19 extra digits + {{0x6BC75E2D630FFFFFull, 0x5ull} + } + , //20 + {{0x35C9ADC5DE9FFFFFull, 0x36ull} + } + , //21 + {{0x19E0C9BAB23FFFFFull, 0x21eull} + } + , //22 + {{0x2C7E14AF67FFFFFull, 0x152dull} + } + , //23 + {{0x1BCECCEDA0FFFFFFull, 0xd3c2ull} + } + , //24 + {{0x1614014849FFFFFFull, 0x84595ull} + } + , //25 + {{0xDCC80CD2E3FFFFFFull, 0x52b7d2ull} + } + , //26 + {{0x9FD0803CE7FFFFFFull, 0x33B2E3Cull} + } + , //27 + {{0x3E2502610FFFFFFFull, 0x204FCE5Eull} + } + , //28 + {{0x6D7217CA9FFFFFFFull, 0x1431E0FAEull} + } + , //29 + {{0x4674EDEA3FFFFFFFull, 0xC9F2C9CD0ull} + } + , //30 + {{0xC0914B267FFFFFFFull, 0x7E37BE2022ull} + } + , //31 + {{0x85ACEF80FFFFFFFFull, 0x4EE2D6D415Bull} + } + , //32 + {{0x38c15b09ffffffffull, 0x314dc6448d93ull} + } + , //33 + {{0x378d8e63ffffffffull, 0x1ed09bead87c0ull} + } + , //34 + {{0x2b878fe7ffffffffull, 0x13426172c74d82ull} + } + , //35 + } + , + { //RZ + {{0ull, 0ull} + } + , // 0 extra digits + {{0ull, 0ull} + } + , // 1 extra digits + {{0ull, 0ull} + } + , // 2 extra digits + {{00ull, 0ull} + } + , // 3 extra digits + {{000ull, 0ull} + } + , // 4 extra digits + {{0000ull, 0ull} + } + , // 5 extra digits + {{00000ull, 0ull} + } + , // 6 extra digits + {{000000ull, 0ull} + } + , // 7 extra digits + {{0000000ull, 0ull} + } + , // 8 extra digits + {{00000000ull, 0ull} + } + , // 9 extra digits + {{000000000ull, 0ull} + } + , // 10 extra digits + {{0000000000ull, 0ull} + } + , // 11 extra digits + {{00000000000ull, 0ull} + } + , // 12 extra digits + {{000000000000ull, 0ull} + } + , // 13 extra digits + {{0000000000000ull, 0ull} + } + , // 14 extra digits + {{00000000000000ull, 0ull} + } + , // 15 extra digits + {{000000000000000ull, 0ull} + } + , // 16 extra digits + {{0000000000000000ull, 0ull} + } + , // 17 extra digits + {{00000000000000000ull, 0ull} + } + , // 18 extra digits + {{000000000000000000ull, 0ull} + } + , // 19 extra digits + {{0ull, 0ull} + } + , //20 + {{0ull, 0ull} + } + , //21 + {{0ull, 0ull} + } + , //22 + {{0ull, 0ull} + } + , //23 + {{0ull, 0ull} + } + , //24 + {{0ull, 0ull} + } + , //25 + {{0ull, 0ull} + } + , //26 + {{0ull, 0ull} + } + , //27 + {{0ull, 0ull} + } + , //28 + {{0ull, 0ull} + } + , //29 + {{0ull, 0ull} + } + , //30 + {{0ull, 0ull} + } + , //31 + {{0ull, 0ull} + } + , //32 + {{0ull, 0ull} + } + , //33 + {{0ull, 0ull} + } + , //34 + {{0ull, 0ull} + } + , //35 + } + , + { //RN, ties away + {{0ull, 0ull} + } + , // 0 extra digits + {{5ull, 0ull} + } + , // 1 extra digits + {{50ull, 0ull} + } + , // 2 extra digits + {{500ull, 0ull} + } + , // 3 extra digits + {{5000ull, 0ull} + } + , // 4 extra digits + {{50000ull, 0ull} + } + , // 5 extra digits + {{500000ull, 0ull} + } + , // 6 extra digits + {{5000000ull, 0ull} + } + , // 7 extra digits + {{50000000ull, 0ull} + } + , // 8 extra digits + {{500000000ull, 0ull} + } + , // 9 extra digits + {{5000000000ull, 0ull} + } + , // 10 extra digits + {{50000000000ull, 0ull} + } + , // 11 extra digits + {{500000000000ull, 0ull} + } + , // 12 extra digits + {{5000000000000ull, 0ull} + } + , // 13 extra digits + {{50000000000000ull, 0ull} + } + , // 14 extra digits + {{500000000000000ull, 0ull} + } + , // 15 extra digits + {{5000000000000000ull, 0ull} + } + , // 16 extra digits + {{50000000000000000ull, 0ull} + } + , // 17 extra digits + {{500000000000000000ull, 0ull} + } + , // 18 extra digits + {{5000000000000000000ull, 0ull} + } + , // 19 extra digits + {{0xb5e3af16b1880000ull, 2ull} + } + , //20 + {{0x1ae4d6e2ef500000ull, 27ull} + } + , //21 + {{0xcf064dd59200000ull, 271ull} + } + , //22 + {{0x8163f0a57b400000ull, 2710ull} + } + , //23 + {{0xde76676d0800000ull, 27105ull} + } + , //24 + {{0x8b0a00a425000000ull, 0x422caull} + } + , //25 + {{0x6e64066972000000ull, 0x295be9ull} + } + , //26 + {{0x4fe8401e74000000ull, 0x19d971eull} + } + , //27 + {{0x1f12813088000000ull, 0x1027e72full} + } + , //28 + {{0x36b90be550000000ull, 0xa18f07d7ull} + } + , //29 + {{0x233a76f520000000ull, 0x64f964e68ull} + } + , //30 + {{0x6048a59340000000ull, 0x3f1bdf1011ull} + } + , //31 + {{0xc2d677c080000000ull, 0x27716b6a0adull} + } + , //32 + {{0x9c60ad8500000000ull, 0x18a6e32246c9ull} + } + , //33 + {{0x1bc6c73200000000ull, 0xf684df56c3e0ull} + } + , //34 + {{0x15c3c7f400000000ull, 0x9a130b963a6c1ull} + } + , //35 + } +}; + + +BID_UINT128 bid_reciprocals10_128[] = { + {{0ull, 0ull} + } + , // 0 extra digits + {{0x3333333333333334ull, 0x3333333333333333ull} + } + , // 1 extra digit + {{0x51eb851eb851eb86ull, 0x051eb851eb851eb8ull} + } + , // 2 extra digits + {{0x3b645a1cac083127ull, 0x0083126e978d4fdfull} + } + , // 3 extra digits + {{0x4af4f0d844d013aaULL, 0x00346dc5d6388659ULL} + } + , // 10^(-4) * 2^131 + {{0x08c3f3e0370cdc88ULL, 0x0029f16b11c6d1e1ULL} + } + , // 10^(-5) * 2^134 + {{0x6d698fe69270b06dULL, 0x00218def416bdb1aULL} + } + , // 10^(-6) * 2^137 + {{0xaf0f4ca41d811a47ULL, 0x0035afe535795e90ULL} + } + , // 10^(-7) * 2^141 + {{0xbf3f70834acdaea0ULL, 0x002af31dc4611873ULL} + } + , // 10^(-8) * 2^144 + {{0x65cc5a02a23e254dULL, 0x00225c17d04dad29ULL} + } + , // 10^(-9) * 2^147 + {{0x6fad5cd10396a214ULL, 0x0036f9bfb3af7b75ULL} + } + , // 10^(-10) * 2^151 + {{0xbfbde3da69454e76ULL, 0x002bfaffc2f2c92aULL} + } + , // 10^(-11) * 2^154 + {{0x32fe4fe1edd10b92ULL, 0x00232f33025bd422ULL} + } + , // 10^(-12) * 2^157 + {{0x84ca19697c81ac1cULL, 0x00384b84d092ed03ULL} + } + , // 10^(-13) * 2^161 + {{0x03d4e1213067bce4ULL, 0x002d09370d425736ULL} + } + , // 10^(-14) * 2^164 + {{0x3643e74dc052fd83ULL, 0x0024075f3dceac2bULL} + } + , // 10^(-15) * 2^167 + {{0x56d30baf9a1e626bULL, 0x0039a5652fb11378ULL} + } + , // 10^(-16) * 2^171 + {{0x12426fbfae7eb522ULL, 0x002e1dea8c8da92dULL} + } + , // 10^(-17) * 2^174 + {{0x41cebfcc8b9890e8ULL, 0x0024e4bba3a48757ULL} + } + , // 10^(-18) * 2^177 + {{0x694acc7a78f41b0dULL, 0x003b07929f6da558ULL} + } + , // 10^(-19) * 2^181 + {{0xbaa23d2ec729af3eULL, 0x002f394219248446ULL} + } + , // 10^(-20) * 2^184 + {{0xfbb4fdbf05baf298ULL, 0x0025c768141d369eULL} + } + , // 10^(-21) * 2^187 + {{0x2c54c931a2c4b759ULL, 0x003c7240202ebdcbULL} + } + , // 10^(-22) * 2^191 + {{0x89dd6dc14f03c5e1ULL, 0x00305b66802564a2ULL} + } + , // 10^(-23) * 2^194 + {{0xd4b1249aa59c9e4eULL, 0x0026af8533511d4eULL} + } + , // 10^(-24) * 2^197 + {{0x544ea0f76f60fd49ULL, 0x003de5a1ebb4fbb1ULL} + } + , // 10^(-25) * 2^201 + {{0x76a54d92bf80caa1ULL, 0x00318481895d9627ULL} + } + , // 10^(-26) * 2^204 + {{0x921dd7a89933d54eULL, 0x00279d346de4781fULL} + } + , // 10^(-27) * 2^207 + {{0x8362f2a75b862215ULL, 0x003f61ed7ca0c032ULL} + } + , // 10^(-28) * 2^211 + {{0xcf825bb91604e811ULL, 0x0032b4bdfd4d668eULL} + } + , // 10^(-29) * 2^214 + {{0x0c684960de6a5341ULL, 0x00289097fdd7853fULL} + } + , // 10^(-30) * 2^217 + {{0x3d203ab3e521dc34ULL, 0x002073accb12d0ffULL} + } + , // 10^(-31) * 2^220 + {{0x2e99f7863b696053ULL, 0x0033ec47ab514e65ULL} + } + , // 10^(-32) * 2^224 + {{0x587b2c6b62bab376ULL, 0x002989d2ef743eb7ULL} + } + , // 10^(-33) * 2^227 + {{0xad2f56bc4efbc2c5ULL, 0x00213b0f25f69892ULL} + } + , // 10^(-34) * 2^230 + {{0x0f2abc9d8c9689d1ull, 0x01a95a5b7f87a0efull} + } + , // 35 extra digits +}; + + +int bid_recip_scale[] = { + 129 - 128, // 1 + 129 - 128, // 1/10 + 129 - 128, // 1/10^2 + 129 - 128, // 1/10^3 + 3, // 131 - 128 + 6, // 134 - 128 + 9, // 137 - 128 + 13, // 141 - 128 + 16, // 144 - 128 + 19, // 147 - 128 + 23, // 151 - 128 + 26, // 154 - 128 + 29, // 157 - 128 + 33, // 161 - 128 + 36, // 164 - 128 + 39, // 167 - 128 + 43, // 171 - 128 + 46, // 174 - 128 + 49, // 177 - 128 + 53, // 181 - 128 + 56, // 184 - 128 + 59, // 187 - 128 + 63, // 191 - 128 + + 66, // 194 - 128 + 69, // 197 - 128 + 73, // 201 - 128 + 76, // 204 - 128 + 79, // 207 - 128 + 83, // 211 - 128 + 86, // 214 - 128 + 89, // 217 - 128 + 92, // 220 - 128 + 96, // 224 - 128 + 99, // 227 - 128 + 102, // 230 - 128 + 109, // 237 - 128, 1/10^35 +}; + + +// tables used in computation +int bid_estimate_decimal_digits[129] = { + 1, //2^0 =1 < 10^0 + 1, //2^1 =2 < 10^1 + 1, //2^2 =4 < 10^1 + 1, //2^3 =8 < 10^1 + 2, //2^4 =16 < 10^2 + 2, //2^5 =32 < 10^2 + 2, //2^6 =64 < 10^2 + 3, //2^7 =128 < 10^3 + 3, //2^8 =256 < 10^3 + 3, //2^9 =512 < 10^3 + 4, //2^10=1024 < 10^4 + 4, //2^11=2048 < 10^4 + 4, //2^12=4096 < 10^4 + 4, //2^13=8192 < 10^4 + 5, //2^14=16384 < 10^5 + 5, //2^15=32768 < 10^5 + + 5, //2^16=65536 < 10^5 + 6, //2^17=131072 < 10^6 + 6, //2^18=262144 < 10^6 + 6, //2^19=524288 < 10^6 + 7, //2^20=1048576 < 10^7 + 7, //2^21=2097152 < 10^7 + 7, //2^22=4194304 < 10^7 + 7, //2^23=8388608 < 10^7 + 8, //2^24=16777216 < 10^8 + 8, //2^25=33554432 < 10^8 + 8, //2^26=67108864 < 10^8 + 9, //2^27=134217728 < 10^9 + 9, //2^28=268435456 < 10^9 + 9, //2^29=536870912 < 10^9 + 10, //2^30=1073741824< 10^10 + 10, //2^31=2147483648< 10^10 + + 10, //2^32=4294967296 < 10^10 + 10, //2^33=8589934592 < 10^10 + 11, //2^34=17179869184 < 10^11 + 11, //2^35=34359738368 < 10^11 + 11, //2^36=68719476736 < 10^11 + 12, //2^37=137438953472 < 10^12 + 12, //2^38=274877906944 < 10^12 + 12, //2^39=549755813888 < 10^12 + 13, //2^40=1099511627776 < 10^13 + 13, //2^41=2199023255552 < 10^13 + 13, //2^42=4398046511104 < 10^13 + 13, //2^43=8796093022208 < 10^13 + 14, //2^44=17592186044416 < 10^14 + 14, //2^45=35184372088832 < 10^14 + 14, //2^46=70368744177664 < 10^14 + 15, //2^47=140737488355328< 10^15 + + 15, //2^48=281474976710656 < 10^15 + 15, //2^49=562949953421312 < 10^15 + 16, //2^50=1125899906842624 < 10^16 + 16, //2^51=2251799813685248 < 10^16 + 16, //2^52=4503599627370496 < 10^16 + 16, //2^53=9007199254740992 < 10^16 + 17, //2^54=18014398509481984 < 10^17 + 17, //2^55=36028797018963968 < 10^17 + 17, //2^56=72057594037927936 < 10^17 + 18, //2^57=144115188075855872 < 10^18 + 18, //2^58=288230376151711744 < 10^18 + 18, //2^59=576460752303423488 < 10^18 + 19, //2^60=1152921504606846976< 10^19 + 19, //2^61=2305843009213693952< 10^19 + 19, //2^62=4611686018427387904< 10^19 + 19, //2^63=9223372036854775808< 10^19 + + 20, //2^64=18446744073709551616 + 20, //2^65=36893488147419103232 + 20, //2^66=73786976294838206464 + 21, //2^67=147573952589676412928 + 21, //2^68=295147905179352825856 + 21, //2^69=590295810358705651712 + 22, //2^70=1180591620717411303424 + 22, //2^71=2361183241434822606848 + 22, //2^72=4722366482869645213696 + 22, //2^73=9444732965739290427392 + 23, //2^74=18889465931478580854784 + 23, //2^75=37778931862957161709568 + 23, //2^76=75557863725914323419136 + 24, //2^77=151115727451828646838272 + 24, //2^78=302231454903657293676544 + 24, //2^79=604462909807314587353088 + + 25, //2^80=1208925819614629174706176 + 25, //2^81=2417851639229258349412352 + 25, //2^82=4835703278458516698824704 + 25, //2^83=9671406556917033397649408 + 26, //2^84=19342813113834066795298816 + 26, //2^85=38685626227668133590597632 + 26, //2^86=77371252455336267181195264 + 27, //2^87=154742504910672534362390528 + 27, //2^88=309485009821345068724781056 + 27, //2^89=618970019642690137449562112 + 28, //2^90=1237940039285380274899124224 + 28, //2^91=2475880078570760549798248448 + 28, //2^92=4951760157141521099596496896 + 28, //2^93=9903520314283042199192993792 + 29, //2^94=19807040628566084398385987584 + 29, //2^95=39614081257132168796771975168 + 29, //2^96=79228162514264337593543950336 + + 30, //2^97=158456325028528675187087900672 + 30, //2^98=316912650057057350374175801344 + 30, //2^99=633825300114114700748351602688 + 31, //2^100=1267650600228229401496703205376 + 31, //2^101=2535301200456458802993406410752 + 31, //2^102=5070602400912917605986812821504 + 32, //2^103=10141204801825835211973625643008 + 32, //2^104=20282409603651670423947251286016 + 32, //2^105=40564819207303340847894502572032 + 32, //2^106=81129638414606681695789005144064 + 33, //2^107=162259276829213363391578010288128 + 33, // 2^108 + 33, // 2^109 + 34, // 2^110 + 34, // 2^111 + 34, // 2^112 + 35, // 2^113 + 35, // 2^114 + 35, // 2^115 + 35, // 2^116 + 36, // 2^117 + 36, // 2^118 + 36, // 2^119 + 37, // 2^120 + 37, // 2^121 + 37, // 2^122 + 38, // 2^123 + 38, // 2^124 + 38, // 2^125 + 38, // 2^126 + 39, // 2^127 + 39 // 2^128 +}; + + +BID_UINT128 bid_power10_table_128[] = { + {{0x0000000000000001ull, 0x0000000000000000ull}}, // 10^0 + {{0x000000000000000aull, 0x0000000000000000ull}}, // 10^1 + {{0x0000000000000064ull, 0x0000000000000000ull}}, // 10^2 + {{0x00000000000003e8ull, 0x0000000000000000ull}}, // 10^3 + {{0x0000000000002710ull, 0x0000000000000000ull}}, // 10^4 + {{0x00000000000186a0ull, 0x0000000000000000ull}}, // 10^5 + {{0x00000000000f4240ull, 0x0000000000000000ull}}, // 10^6 + {{0x0000000000989680ull, 0x0000000000000000ull}}, // 10^7 + {{0x0000000005f5e100ull, 0x0000000000000000ull}}, // 10^8 + {{0x000000003b9aca00ull, 0x0000000000000000ull}}, // 10^9 + {{0x00000002540be400ull, 0x0000000000000000ull}}, // 10^10 + {{0x000000174876e800ull, 0x0000000000000000ull}}, // 10^11 + {{0x000000e8d4a51000ull, 0x0000000000000000ull}}, // 10^12 + {{0x000009184e72a000ull, 0x0000000000000000ull}}, // 10^13 + {{0x00005af3107a4000ull, 0x0000000000000000ull}}, // 10^14 + {{0x00038d7ea4c68000ull, 0x0000000000000000ull}}, // 10^15 + {{0x002386f26fc10000ull, 0x0000000000000000ull}}, // 10^16 + {{0x016345785d8a0000ull, 0x0000000000000000ull}}, // 10^17 + {{0x0de0b6b3a7640000ull, 0x0000000000000000ull}}, // 10^18 + {{0x8ac7230489e80000ull, 0x0000000000000000ull}}, // 10^19 + {{0x6bc75e2d63100000ull, 0x0000000000000005ull}}, // 10^20 + {{0x35c9adc5dea00000ull, 0x0000000000000036ull}}, // 10^21 + {{0x19e0c9bab2400000ull, 0x000000000000021eull}}, // 10^22 + {{0x02c7e14af6800000ull, 0x000000000000152dull}}, // 10^23 + {{0x1bcecceda1000000ull, 0x000000000000d3c2ull}}, // 10^24 + {{0x161401484a000000ull, 0x0000000000084595ull}}, // 10^25 + {{0xdcc80cd2e4000000ull, 0x000000000052b7d2ull}}, // 10^26 + {{0x9fd0803ce8000000ull, 0x00000000033b2e3cull}}, // 10^27 + {{0x3e25026110000000ull, 0x00000000204fce5eull}}, // 10^28 + {{0x6d7217caa0000000ull, 0x00000001431e0faeull}}, // 10^29 + {{0x4674edea40000000ull, 0x0000000c9f2c9cd0ull}}, // 10^30 + {{0xc0914b2680000000ull, 0x0000007e37be2022ull}}, // 10^31 + {{0x85acef8100000000ull, 0x000004ee2d6d415bull}}, // 10^32 + {{0x38c15b0a00000000ull, 0x0000314dc6448d93ull}}, // 10^33 + {{0x378d8e6400000000ull, 0x0001ed09bead87c0ull}}, // 10^34 + {{0x2b878fe800000000ull, 0x0013426172c74d82ull}}, // 10^35 + {{0xb34b9f1000000000ull, 0x00c097ce7bc90715ull}}, // 10^36 + {{0x00f436a000000000ull, 0x0785ee10d5da46d9ull}}, // 10^37 + {{0x098a224000000000ull, 0x4b3b4ca85a86c47aull}}, // 10^38 +}; + + +int bid_estimate_bin_expon[] = { + 0, // 10^0 + 3, // 10^1 + 6, // 10^2 + 9, // 10^3 + 13, // 10^4 + 16, // 10^5 + 19, // 10^6 + 23, // 10^7 + 26, // 10^8 + 29, // 10^9 + 33, // 10^10 + 36, // 10^11 + 39, // 10^12 + 43, // 10^13 + 46, // 10^14 + 49, // 10^15 + 53 // 10^16 +}; + + +BID_UINT64 bid_power10_index_binexp[] = { + 0x000000000000000aull, + 0x000000000000000aull, + 0x000000000000000aull, + 0x000000000000000aull, + 0x0000000000000064ull, + 0x0000000000000064ull, + 0x0000000000000064ull, + 0x00000000000003e8ull, + 0x00000000000003e8ull, + 0x00000000000003e8ull, + 0x0000000000002710ull, + 0x0000000000002710ull, + 0x0000000000002710ull, + 0x0000000000002710ull, + 0x00000000000186a0ull, + 0x00000000000186a0ull, + 0x00000000000186a0ull, + 0x00000000000f4240ull, + 0x00000000000f4240ull, + 0x00000000000f4240ull, + 0x0000000000989680ull, + 0x0000000000989680ull, + 0x0000000000989680ull, + 0x0000000000989680ull, + 0x0000000005f5e100ull, + 0x0000000005f5e100ull, + 0x0000000005f5e100ull, + 0x000000003b9aca00ull, + 0x000000003b9aca00ull, + 0x000000003b9aca00ull, + 0x00000002540be400ull, + 0x00000002540be400ull, + 0x00000002540be400ull, + 0x00000002540be400ull, + 0x000000174876e800ull, + 0x000000174876e800ull, + 0x000000174876e800ull, + 0x000000e8d4a51000ull, + 0x000000e8d4a51000ull, + 0x000000e8d4a51000ull, + 0x000009184e72a000ull, + 0x000009184e72a000ull, + 0x000009184e72a000ull, + 0x000009184e72a000ull, + 0x00005af3107a4000ull, + 0x00005af3107a4000ull, + 0x00005af3107a4000ull, + 0x00038d7ea4c68000ull, + 0x00038d7ea4c68000ull, + 0x00038d7ea4c68000ull, + 0x002386f26fc10000ull, + 0x002386f26fc10000ull, + 0x002386f26fc10000ull, + 0x002386f26fc10000ull, + 0x016345785d8a0000ull, + 0x016345785d8a0000ull, + 0x016345785d8a0000ull, + 0x0de0b6b3a7640000ull, + 0x0de0b6b3a7640000ull, + 0x0de0b6b3a7640000ull, + 0x8ac7230489e80000ull, + 0x8ac7230489e80000ull, + 0x8ac7230489e80000ull, + 0x8ac7230489e80000ull +}; + + +int bid_short_recip_scale[] = { + 1, + 65 - 64, + 69 - 64, + 71 - 64, + 75 - 64, + 78 - 64, + 81 - 64, + 85 - 64, + 88 - 64, + 91 - 64, + 95 - 64, + 98 - 64, + 101 - 64, + 105 - 64, + 108 - 64, + 111 - 64, + 115 - 64, //114 - 64 + 118 - 64 +}; + + +BID_UINT64 bid_reciprocals10_64[] = { + 1ull, // dummy value for 0 extra digits + 0x3333333333333334ull, // 1 extra digit + 0x51eb851eb851eb86ull, + 0x20c49ba5e353f7cfull, + 0x346dc5d63886594bull, + 0x29f16b11c6d1e109ull, + 0x218def416bdb1a6eull, + 0x35afe535795e90b0ull, + 0x2af31dc4611873c0ull, + 0x225c17d04dad2966ull, + 0x36f9bfb3af7b7570ull, + 0x2bfaffc2f2c92ac0ull, + 0x232f33025bd42233ull, + 0x384b84d092ed0385ull, + 0x2d09370d42573604ull, + 0x24075f3dceac2b37ull, + 0x39a5652fb1137857ull, + 0x2e1dea8c8da92d13ull +}; + +int bid_bid_bid_recip_scale32 [] = +{ + 1, + 33-32, + 35-32, + 39-32, + 43-32, + 46-32, + 50-32, + 53-32, + 57-32 +}; + + +BID_UINT64 bid_bid_reciprocals10_32[] = { + 1ull, //dummy, + 0x33333334ull, + 0x147AE148ull, + 0x20C49BA6ull, + 0x346DC5D7ull, //4 + 0x29F16B12ull, + 0x431BDE83ull, + 0x35AFE536ull, + 0x55E63B89ull +}; + + + +BID_UINT128 bid_power10_index_binexp_128[] = { + {{0x000000000000000aull, 0x0000000000000000ull}}, + {{0x000000000000000aull, 0x0000000000000000ull}}, + {{0x000000000000000aull, 0x0000000000000000ull}}, + {{0x000000000000000aull, 0x0000000000000000ull}}, + {{0x0000000000000064ull, 0x0000000000000000ull}}, + {{0x0000000000000064ull, 0x0000000000000000ull}}, + {{0x0000000000000064ull, 0x0000000000000000ull}}, + {{0x00000000000003e8ull, 0x0000000000000000ull}}, + {{0x00000000000003e8ull, 0x0000000000000000ull}}, + {{0x00000000000003e8ull, 0x0000000000000000ull}}, + {{0x0000000000002710ull, 0x0000000000000000ull}}, + {{0x0000000000002710ull, 0x0000000000000000ull}}, + {{0x0000000000002710ull, 0x0000000000000000ull}}, + {{0x0000000000002710ull, 0x0000000000000000ull}}, + {{0x00000000000186a0ull, 0x0000000000000000ull}}, + {{0x00000000000186a0ull, 0x0000000000000000ull}}, + {{0x00000000000186a0ull, 0x0000000000000000ull}}, + {{0x00000000000f4240ull, 0x0000000000000000ull}}, + {{0x00000000000f4240ull, 0x0000000000000000ull}}, + {{0x00000000000f4240ull, 0x0000000000000000ull}}, + {{0x0000000000989680ull, 0x0000000000000000ull}}, + {{0x0000000000989680ull, 0x0000000000000000ull}}, + {{0x0000000000989680ull, 0x0000000000000000ull}}, + {{0x0000000000989680ull, 0x0000000000000000ull}}, + {{0x0000000005f5e100ull, 0x0000000000000000ull}}, + {{0x0000000005f5e100ull, 0x0000000000000000ull}}, + {{0x0000000005f5e100ull, 0x0000000000000000ull}}, + {{0x000000003b9aca00ull, 0x0000000000000000ull}}, + {{0x000000003b9aca00ull, 0x0000000000000000ull}}, + {{0x000000003b9aca00ull, 0x0000000000000000ull}}, + {{0x00000002540be400ull, 0x0000000000000000ull}}, + {{0x00000002540be400ull, 0x0000000000000000ull}}, + {{0x00000002540be400ull, 0x0000000000000000ull}}, + {{0x00000002540be400ull, 0x0000000000000000ull}}, + {{0x000000174876e800ull, 0x0000000000000000ull}}, + {{0x000000174876e800ull, 0x0000000000000000ull}}, + {{0x000000174876e800ull, 0x0000000000000000ull}}, + {{0x000000e8d4a51000ull, 0x0000000000000000ull}}, + {{0x000000e8d4a51000ull, 0x0000000000000000ull}}, + {{0x000000e8d4a51000ull, 0x0000000000000000ull}}, + {{0x000009184e72a000ull, 0x0000000000000000ull}}, + {{0x000009184e72a000ull, 0x0000000000000000ull}}, + {{0x000009184e72a000ull, 0x0000000000000000ull}}, + {{0x000009184e72a000ull, 0x0000000000000000ull}}, + {{0x00005af3107a4000ull, 0x0000000000000000ull}}, + {{0x00005af3107a4000ull, 0x0000000000000000ull}}, + {{0x00005af3107a4000ull, 0x0000000000000000ull}}, + {{0x00038d7ea4c68000ull, 0x0000000000000000ull}}, + {{0x00038d7ea4c68000ull, 0x0000000000000000ull}}, + {{0x00038d7ea4c68000ull, 0x0000000000000000ull}}, + {{0x002386f26fc10000ull, 0x0000000000000000ull}}, + {{0x002386f26fc10000ull, 0x0000000000000000ull}}, + {{0x002386f26fc10000ull, 0x0000000000000000ull}}, + {{0x002386f26fc10000ull, 0x0000000000000000ull}}, + {{0x016345785d8a0000ull, 0x0000000000000000ull}}, + {{0x016345785d8a0000ull, 0x0000000000000000ull}}, + {{0x016345785d8a0000ull, 0x0000000000000000ull}}, + {{0x0de0b6b3a7640000ull, 0x0000000000000000ull}}, + {{0x0de0b6b3a7640000ull, 0x0000000000000000ull}}, + {{0x0de0b6b3a7640000ull, 0x0000000000000000ull}}, + {{0x8ac7230489e80000ull, 0x0000000000000000ull}}, + {{0x8ac7230489e80000ull, 0x0000000000000000ull}}, + {{0x8ac7230489e80000ull, 0x0000000000000000ull}}, + {{0x8ac7230489e80000ull, 0x0000000000000000ull}}, + {{0x6bc75e2d63100000ull, 0x0000000000000005ull}}, // 10^20 + {{0x6bc75e2d63100000ull, 0x0000000000000005ull}}, // 10^20 + {{0x6bc75e2d63100000ull, 0x0000000000000005ull}}, // 10^20 + {{0x35c9adc5dea00000ull, 0x0000000000000036ull}}, // 10^21 + {{0x35c9adc5dea00000ull, 0x0000000000000036ull}}, // 10^21 + {{0x35c9adc5dea00000ull, 0x0000000000000036ull}}, // 10^21 + {{0x19e0c9bab2400000ull, 0x000000000000021eull}}, // 10^22 + {{0x19e0c9bab2400000ull, 0x000000000000021eull}}, // 10^22 + {{0x19e0c9bab2400000ull, 0x000000000000021eull}}, // 10^22 + {{0x19e0c9bab2400000ull, 0x000000000000021eull}}, // 10^22 + {{0x02c7e14af6800000ull, 0x000000000000152dull}}, // 10^23 + {{0x02c7e14af6800000ull, 0x000000000000152dull}}, // 10^23 + {{0x02c7e14af6800000ull, 0x000000000000152dull}}, // 10^23 + {{0x1bcecceda1000000ull, 0x000000000000d3c2ull}}, // 10^24 + {{0x1bcecceda1000000ull, 0x000000000000d3c2ull}}, // 10^24 + {{0x1bcecceda1000000ull, 0x000000000000d3c2ull}}, // 10^24 + {{0x161401484a000000ull, 0x0000000000084595ull}}, // 10^25 + {{0x161401484a000000ull, 0x0000000000084595ull}}, // 10^25 + {{0x161401484a000000ull, 0x0000000000084595ull}}, // 10^25 + {{0x161401484a000000ull, 0x0000000000084595ull}}, // 10^25 + {{0xdcc80cd2e4000000ull, 0x000000000052b7d2ull}}, // 10^26 + {{0xdcc80cd2e4000000ull, 0x000000000052b7d2ull}}, // 10^26 + {{0xdcc80cd2e4000000ull, 0x000000000052b7d2ull}}, // 10^26 + {{0x9fd0803ce8000000ull, 0x00000000033b2e3cull}}, // 10^27 + {{0x9fd0803ce8000000ull, 0x00000000033b2e3cull}}, // 10^27 + {{0x9fd0803ce8000000ull, 0x00000000033b2e3cull}}, // 10^27 + {{0x3e25026110000000ull, 0x00000000204fce5eull}}, // 10^28 + {{0x3e25026110000000ull, 0x00000000204fce5eull}}, // 10^28 + {{0x3e25026110000000ull, 0x00000000204fce5eull}}, // 10^28 + {{0x3e25026110000000ull, 0x00000000204fce5eull}}, // 10^28 + {{0x6d7217caa0000000ull, 0x00000001431e0faeull}}, // 10^29 + {{0x6d7217caa0000000ull, 0x00000001431e0faeull}}, // 10^29 + {{0x6d7217caa0000000ull, 0x00000001431e0faeull}}, // 10^29 + {{0x4674edea40000000ull, 0x0000000c9f2c9cd0ull}}, // 10^30 + {{0x4674edea40000000ull, 0x0000000c9f2c9cd0ull}}, // 10^30 + {{0x4674edea40000000ull, 0x0000000c9f2c9cd0ull}}, // 10^30 + {{0xc0914b2680000000ull, 0x0000007e37be2022ull}}, // 10^31 + {{0xc0914b2680000000ull, 0x0000007e37be2022ull}}, // 10^31 + {{0xc0914b2680000000ull, 0x0000007e37be2022ull}}, // 10^31 + {{0x85acef8100000000ull, 0x000004ee2d6d415bull}}, // 10^32 + {{0x85acef8100000000ull, 0x000004ee2d6d415bull}}, // 10^32 + {{0x85acef8100000000ull, 0x000004ee2d6d415bull}}, // 10^32 + {{0x85acef8100000000ull, 0x000004ee2d6d415bull}}, // 10^32 + {{0x38c15b0a00000000ull, 0x0000314dc6448d93ull}}, // 10^33 + {{0x38c15b0a00000000ull, 0x0000314dc6448d93ull}}, // 10^33 + {{0x38c15b0a00000000ull, 0x0000314dc6448d93ull}}, // 10^33, entry 112 + {{0x378d8e6400000000ull, 0x0001ed09bead87c0ull}}, // 10^34 + {{0x378d8e6400000000ull, 0x0001ed09bead87c0ull}}, // 10^34 + {{0x378d8e6400000000ull, 0x0001ed09bead87c0ull}}, // 10^34 + {{0x2b878fe800000000ull, 0x0013426172c74d82ull}}, // 10^35 + {{0x2b878fe800000000ull, 0x0013426172c74d82ull}}, // 10^35 + {{0x2b878fe800000000ull, 0x0013426172c74d82ull}}, // 10^35 + {{0x2b878fe800000000ull, 0x0013426172c74d82ull}}, // 10^35 + {{0xb34b9f1000000000ull, 0x00c097ce7bc90715ull}}, // 10^36 + {{0x00f436a000000000ull, 0x0785ee10d5da46d9ull}}, // 10^37 + {{0x00f436a000000000ull, 0x0785ee10d5da46d9ull}}, // 10^37 + {{0x00f436a000000000ull, 0x0785ee10d5da46d9ull}}, // 10^37 + {{0x098a224000000000ull, 0x4b3b4ca85a86c47aull}}, // 10^38 + {{0x098a224000000000ull, 0x4b3b4ca85a86c47aull}}, // 10^38 + {{0x098a224000000000ull, 0x4b3b4ca85a86c47aull}}, // 10^38 + {{0x098a224000000000ull, 0x4b3b4ca85a86c47aull}}, // 10^38 +}; diff --git a/reftest/bid_decimal_globals.c b/reftest/bid_decimal_globals.c new file mode 100644 index 0000000..c54e17f --- /dev/null +++ b/reftest/bid_decimal_globals.c @@ -0,0 +1,106 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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 "bid_internal.h" +#include "bid_gcc_intrinsics.h" + +#if DECIMAL_GLOBAL_ROUNDING +BID_THREAD _IDEC_round _IDEC_glbround = BID_ROUNDING_TO_NEAREST; + +#if DECIMAL_GLOBAL_ROUNDING_ACCESS_FUNCTIONS +void +__dfp_set_round (int mode) { + _IDEC_glbround = mode; +} + +int +__dfp_get_round (void) { + return _IDEC_glbround; +} +#endif +#endif + +#if DECIMAL_GLOBAL_EXCEPTION_FLAGS +BID_THREAD _IDEC_flags _IDEC_glbflags = BID_EXACT_STATUS; + +#if DECIMAL_GLOBAL_EXCEPTION_FLAGS_ACCESS_FUNCTIONS +#include + +void +__dfp_clear_except (void) { + _IDEC_glbflags &= ~BID_FLAG_MASK; +} + +int +__dfp_test_except (int mask) { + int flags = 0; + + if ((_IDEC_glbflags & BID_INEXACT_EXCEPTION) != 0) + flags |= mask & FE_INEXACT; + if ((_IDEC_glbflags & BID_UNDERFLOW_EXCEPTION) != 0) + flags |= mask & FE_UNDERFLOW; + if ((_IDEC_glbflags & BID_OVERFLOW_EXCEPTION) != 0) + flags |= mask & FE_OVERFLOW; + if ((_IDEC_glbflags & BID_ZERO_DIVIDE_EXCEPTION) != 0) + flags |= mask & FE_DIVBYZERO; + if ((_IDEC_glbflags & BID_INVALID_EXCEPTION) != 0) + flags |= mask & FE_INVALID; + + return flags; +} + +void +__dfp_raise_except (int mask) { + _IDEC_flags flags = 0; + + if ((mask & FE_INEXACT) != 0) + flags |= BID_INEXACT_EXCEPTION; + if ((mask & FE_UNDERFLOW) != 0) + flags |= BID_UNDERFLOW_EXCEPTION; + if ((mask & FE_OVERFLOW) != 0) + flags |= BID_OVERFLOW_EXCEPTION; + if ((mask & FE_DIVBYZERO) != 0) + flags |= BID_ZERO_DIVIDE_EXCEPTION; + if ((mask & FE_INVALID) != 0) + flags |= BID_INVALID_EXCEPTION; + + _IDEC_glbflags |= flags; +} +#endif +#endif + +#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING +#if DECIMAL_GLOBAL_EXCEPTION_MASKS +BID_THREAD _IDEC_exceptionmasks _IDEC_glbexceptionmasks = + _IDEC_allexcmasksset; +#endif +#if DECIMAL_GLOBAL_EXCEPTION_INFO +BID_THREAD _IDEC_excepthandling _IDEC_glbexcepthandling; +#endif +#endif diff --git a/reftest/bid_functions.h b/reftest/bid_functions.h new file mode 100644 index 0000000..eaa5def --- /dev/null +++ b/reftest/bid_functions.h @@ -0,0 +1,5268 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +#if defined(__cplusplus) +#define BID_EXTERN_C extern "C" +#else +#define BID_EXTERN_C extern +#endif + +#ifndef _BID_FUNCTIONS_H +#define _BID_FUNCTIONS_H + +#if !defined (__GNUC__) || defined(__QNX__) +#include +#endif +#include + +// Fix system header issue on Sun solaris and define required type by ourselves +#if !defined(_WCHAR_T) && !defined(_WCHAR_T_DEFINED) && !defined(__QNX__) +typedef int wchar_t; +#endif + + +#ifdef IN_LIBGCC2 +// When we are built as the part of the gcc runtime library, libgcc, +// we will use gcc types defined in bid_gcc_intrinsics.h. +#include "bid_gcc_intrinsics.h" + +#define BID_ALIGN(n) __attribute__ ((aligned(n))) +#else +typedef char BID_SINT8; +typedef unsigned char BID_UINT8; +typedef unsigned BID_UINT32; +typedef signed BID_SINT32; + +#ifdef __GNUC__ +#define bid__int64 long long +#else +#define bid__int64 __int64 +#endif + +#if defined __GNUC__ || defined LINUX || defined SUNOS +typedef unsigned long long BID_UINT64; +typedef signed long long BID_SINT64; +#else +typedef unsigned bid__int64 BID_UINT64; +typedef signed bid__int64 BID_SINT64; +#endif + +#if defined _MSC_VER +#if defined _M_IX86 && !defined __INTEL_COMPILER // Win IA-32, MS compiler +#define BID_ALIGN(n) +#else +#define BID_ALIGN(n) __declspec(align(n)) +#endif +#else +#if !defined HPUX_OS +#define BID_ALIGN(n) __attribute__ ((aligned(n))) +#else +#define BID_ALIGN(n) +#endif +#endif + +// bid_gcc_intrinsics.h will also define this. +typedef struct BID_ALIGN (16) + { + BID_UINT64 w[2]; + } BID_UINT128; +#endif + +#if !((defined __INTEL_COMPILER) || (defined __INTEL_LLVM_COMPILER)) +typedef BID_UINT128 _Quad; +#endif + +#if defined __NO_BINARY80__ +#define __ENABLE_BINARY80__ 0 +#else +#if !defined _MSC_VER || defined __INTEL_COMPILER || defined __INTEL_LLVM_COMPILER +#define __ENABLE_BINARY80__ 1 +#endif +#endif + +#ifndef HPUX_OS + #define BINARY80 long double + #if ((defined __INTEL_COMPILER) || (defined __INTEL_LLVM_COMPILER)) && USE_COMPILER_F128_TYPE + #define BINARY128 _Quad + #else + #define BINARY128 BID_UINT128 + #endif + #define SQRT80 sqrtl +#else + #define BINARY80 __float80 + //#define BINARY128 __float128 + #define BINARY128 BID_UINT128 + #define SQRT80 sqrtw +#endif + + typedef struct BID_ALIGN (16) + { + BID_UINT64 w[3]; + } BID_UINT192; + typedef struct BID_ALIGN (16) + { + BID_UINT64 w[4]; + } BID_UINT256; + typedef unsigned int BID_FPSC; // floating-point status and control + +// TYPE parameters +#define BID128_MAXDIGITS 34 +#define BID64_MAXDIGITS 16 +#define BID32_MAXDIGITS 7 + +// rounding modes +#define BID_ROUNDING_TO_NEAREST 0x00000 +#define BID_ROUNDING_DOWN 0x00001 +#define BID_ROUNDING_UP 0x00002 +#define BID_ROUNDING_TO_ZERO 0x00003 +#define BID_ROUNDING_TIES_AWAY 0x00004 + +#define BID_RMODE_MASK (BID_ROUNDING_TO_NEAREST | BID_ROUNDING_DOWN | BID_ROUNDING_UP | BID_ROUNDING_TO_ZERO | BID_ROUNDING_TIES_AWAY) + +// status +#define BID_FLAG_MASK 0x0000003f +#define DEC_FE_ALL_EXCEPT 0x0000003f +#define BID_IEEE_FLAGS 0x0000003d +#define BID_EXACT_STATUS 0x00000000 + +/////////////////////////////////////////////////////// +// This section may move to fenv_support.h + +#if !defined(__FENV_H_INCLUDED) && !defined (_FENV_H) && !defined(_FENV_INCLUDED) /* Otherwise we already defined fexcept_t type */ +#if defined(__ECL) || defined(__ECC) /* Intel(R) Itanium(R) architecture */ +/* Default 64-bit Floating Point Status Register */ +#if defined(__linux__) +typedef unsigned long fexcept_t; +#else +typedef unsigned bid__int64 fexcept_t; +#endif +#else +#ifdef __QNX__ +#include +#else +typedef unsigned short int fexcept_t; +#endif +#endif +#endif + +typedef enum class_types { + signalingNaN, + quietNaN, + negativeInfinity, + negativeNormal, + negativeSubnormal, + negativeZero, + positiveZero, + positiveSubnormal, + positiveNormal, + positiveInfinity +} class_t; + +#define DEC_FE_INVALID 0x01 +#define DEC_FE_UNNORMAL 0x02 +#define DEC_FE_DIVBYZERO 0x04 +#define DEC_FE_OVERFLOW 0x08 +#define DEC_FE_UNDERFLOW 0x10 +#define DEC_FE_INEXACT 0x20 + +//////////////////////////////////////////////////////// + +#define BID_INEXACT_EXCEPTION DEC_FE_INEXACT +#define BID_UNDERFLOW_EXCEPTION DEC_FE_UNDERFLOW +#define BID_OVERFLOW_EXCEPTION DEC_FE_OVERFLOW +#define BID_ZERO_DIVIDE_EXCEPTION DEC_FE_DIVBYZERO +#define BID_DENORMAL_EXCEPTION DEC_FE_UNNORMAL +#define BID_INVALID_EXCEPTION DEC_FE_INVALID +#define BID_UNDERFLOW_INEXACT_EXCEPTION (DEC_FE_UNDERFLOW|DEC_FE_INEXACT) +#define BID_OVERFLOW_INEXACT_EXCEPTION (DEC_FE_OVERFLOW|DEC_FE_INEXACT) + +#define BID_MODE_MASK 0x00001f80 +#define BID_INEXACT_MODE 0x00001000 +#define BID_UNDERFLOW_MODE 0x00000800 +#define BID_OVERFLOW_MODE 0x00000400 +#define BID_ZERO_DIVIDE_MODE 0x00000200 +#define BID_DENORMAL_MODE 0x00000100 +#define BID_INVALID_MODE 0x00000080 + +#if defined LINUX || defined SUNOS +#define BID_LX16 "%016llx" +#define BID_LX "%llx" +#define BID_LD4 "%4llu" +#define BID_LD16 "%016lld" +#define BID_LD "%lld" +#define BID_LUD "%llu" +#define BID_LUD16 "%016llu" +#define BID_X8 "%08x" +#define BID_X4 "%04x" + +#define BID_FMT_LLX16 "%016llx" +#define BID_FMT_LLX "%llx" +#define BID_FMT_LLU4 "%4llu" +#define BID_FMT_LLD16 "%016lld" +#define BID_FMT_LLD "%lld" +#define BID_FMT_LLU "%llu" +#define BID_FMT_LLU16 "%016llu" +#define BID_FMT_X8 "%08x" +#define BID_FMT_X4 "%04x" +#else +#define BID_LX16 "%016I64x" +#define BID_LX "%I64x" +#define BID_LD16 "%016I64d" +#define BID_LD4 "%4I64u" +#define BID_LD "%I64d" +#define BID_LUD "%I64u" +#define BID_LUD16 "%016I64u" +#define BID_X8 "%08x" +#define BID_X4 "%04x" + +#define BID_FMT_LLX16 "%016I64x" +#define BID_FMT_LLX "%I64x" +#define BID_FMT_LLD16 "%016I64d" +#define BID_FMT_LLU4 "%4I64u" +#define BID_FMT_LLD "%I64d" +#define BID_FMT_LLU "%I64u" +#define BID_FMT_LLU16 "%016I64u" +#define BID_FMT_X8 "%08x" +#define BID_FMT_X4 "%04x" +#endif + +/* rounding modes */ +// typedef unsigned int _IDEC_round; +/*#if DECIMAL_GLOBAL_ROUNDING +BID_EXTERN_C _IDEC_round _IDEC_glbround; // initialized to BID_ROUNDING_TO_NEAREST +#endif*/ + +/* exception flags */ +// typedef unsigned int _IDEC_flags; // could be a struct with diagnostic info +/*#if DECIMAL_GLOBAL_EXCEPTION_FLAGS + BID_EXTERN_C _IDEC_flags _IDEC_glbflags; // initialized to BID_EXACT_STATUS +#endif*/ + +/* exception masks */ + typedef unsigned int _IDEC_exceptionmasks; +/*#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING +#if DECIMAL_GLOBAL_EXCEPTION_MASKS + BID_EXTERN_C _IDEC_exceptionmasks _IDEC_glbexceptionmasks; // initialized to BID_MODE_MASK +#endif +#endif*/ + +#if DECIMAL_ALTERNATE_EXCEPTION_HANDLING + +/* exception information */ + + typedef struct { + unsigned int inexact_result:1; + unsigned int underflow:1; + unsigned int overflow:1; + unsigned int zero_divide:1; + unsigned int invalid_operation:1; + } BID_fpieee_exception_flags_t; + + typedef enum { + _fp_round_nearest, + _fp_round_minus_infinity, + _fp_round_plus_infinity, + _fp_round_chopped, + _fp_round_away + } BID_fpieee_rounding_mode_t; + + typedef enum { + _fp_precision24, + _fp_precision63, + _fp_precision64, + _fp_precision7, + _fp_precision16, + _fp_precision34 + } _fpieee_precision_t; + + typedef enum { + _fp_code_unspecified, + _fp_code_add, + _fp_code_subtract, + _fp_code_multiply, + _fp_code_divide, + _fp_code_square_root, + _fp_code_compare, + _fp_code_convert, + _fp_code_convert_to_integer_neareven, + _fp_code_convert_to_integer_down, + _fp_code_convert_to_integer_up, + _fp_code_convert_to_integer_truncate, + _fp_code_convert_to_integer_nearaway, + _fp_code_fma, + _fp_code_fmin, + _fp_code_fmax, + _fp_code_famin, + _fp_code_famax, + _fp_code_round_to_integral, + _fp_code_minnum, + _fp_code_maxnum, + _fp_code_minnummag, + _fp_code_maxnummag, + _fp_code_quantize, + _fp_code_logb, + _fp_code_scaleb, + _fp_code_remainder, + _fp_code_nextup, + _fp_code_nextdown, + _fp_code_nextafter, + } BID_fp_operation_code_t; + + typedef enum { + _fp_compare_equal, + _fp_compare_greater, + _fp_compare_less, + _fp_compare_unordered + } fpieee_compare_result_t; + + typedef enum { + _fp_format_fp32, + _fp_format_fp64, + _fp_format_fp80, + _fp_format_fp128, + _fp_format_dec_fp32, + _fp_format_dec_fp64, + _fp_format_dec_fp128, + _fp_format_i8, /* 8-bit integer */ + _fp_format_i16, /* 16-bit integer */ + _fp_format_i32, /* 32-bit integer */ + _fp_format_i64, /* 64-bit integer */ + _fp_format_u8, /* 8-bit unsigned integer */ + _fp_format_u16, /* 16-bit unsigned integer */ + _fp_format_u32, /* 32-bit unsigned integer */ + _fp_format_u64, /* 64-bit unsigned integer */ + _fp_format_compare, /* compare value format */ + _fp_format_decimal_char, /* decimal character */ + _fp_format_string /* string */ + } BID_fpieee_format_t; + + typedef struct { + unsigned short W[5]; + } _float80_t; + + typedef struct { + unsigned int W[4]; + } _float128_t; + + typedef struct { + union { + float fp32_value; + double fp64_value; + _float80_t fp80_value; + _float128_t fp128_value; + BID_UINT32 decfp32_value; + BID_UINT64 decfp64_value; + BID_UINT128 decfp128_value; + char i8_value; + short i16_value; + int i32_value; + BID_SINT64 i64_value; + unsigned char u8_value; + unsigned short u16_value; + unsigned int u32_value; + unsigned long u64_value; + fpieee_compare_result_t compare_value; + unsigned char s[256]; + } value; + unsigned int operand_valid:1; + BID_fpieee_format_t format:5; + } BID_fpieee_value_t; + + typedef struct { + unsigned int rounding_mode:3; + unsigned int precision:3; + unsigned int operation:26; + BID_fpieee_exception_flags_t cause; + BID_fpieee_exception_flags_t enable; + BID_fpieee_exception_flags_t status; + BID_fpieee_value_t operand1; + BID_fpieee_value_t operand2; + BID_fpieee_value_t operand3; + BID_fpieee_value_t result; + } _IDEC_excepthandling; + BID_EXTERN_C _IDEC_excepthandling _IDEC_glbexcepthandling; + +#endif + +#if DECIMAL_CALL_BY_REFERENCE + + BID_EXTERN_C void bid_to_dpd32 (BID_UINT32 * pres, BID_UINT32 * px); + BID_EXTERN_C void bid_to_dpd64 (BID_UINT64 * pres, BID_UINT64 * px); + BID_EXTERN_C void bid_to_dpd128 (BID_UINT128 * pres, BID_UINT128 * px); + BID_EXTERN_C void bid_dpd_to_bid32 (BID_UINT32 * pres, BID_UINT32 * px); + BID_EXTERN_C void bid_dpd_to_bid64 (BID_UINT64 * pres, BID_UINT64 * px); + BID_EXTERN_C void bid_dpd_to_bid128 (BID_UINT128 * pres, BID_UINT128 * px); + + BID_EXTERN_C void bid128dd_add (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dq_add (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qd_add (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_add (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dd_sub (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dq_sub (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qd_sub (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_sub (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dd_mul (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dq_mul (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qd_mul (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_mul (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_div (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dd_div (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dq_div (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qd_div (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_fma (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128ddd_fma (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT64 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128ddq_fma (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT64 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dqd_fma (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT128 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128dqq_fma (BID_UINT128 * pres, BID_UINT64 * px, + BID_UINT128 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qdd_fma (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT64 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qdq_fma (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT64 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128qqd_fma (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + // Note: bid128qqq_fma is represented by bid128_fma + // Note: bid64ddd_fma is represented by bid64_fma + BID_EXTERN_C void bid64ddq_fma (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64dqd_fma (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT128 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64dqq_fma (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT128 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qdd_fma (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT64 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qdq_fma (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT64 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qqd_fma (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT128 * py, BID_UINT64 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qqq_fma (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT128 * py, BID_UINT128 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_sqrt (BID_UINT128 * pres, + BID_UINT128 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128d_sqrt (BID_UINT128 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_cbrt (BID_UINT128 * pres, + BID_UINT128 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_exp (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_log (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_pow (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_atan2 (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_fmod (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_modf (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_hypot (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_sin (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_cos (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_tan (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_asin (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_acos (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_atan (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_sinh (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_cosh (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_tanh (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_asinh (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_acosh (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_atanh (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_log1p (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_expm1 (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_log10 (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_log2 (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_exp2 (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_exp10 (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_erf (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_erfc (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_tgamma (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_lgamma (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_exp (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_log (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_pow (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_atan2 (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_fmod (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_modf (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_hypot (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_sin (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_cos (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_tan (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_asin (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_acos (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_atan (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_sinh (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_cosh (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_tanh (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_asinh (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_acosh (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_atanh (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_log1p (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_expm1 (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_log10 (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_log2 (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_exp2 (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_exp10 (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_erf (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_erfc (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_tgamma (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_lgamma (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_exp (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_log (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_pow (BID_UINT128 * pres, BID_UINT128 * px, BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_atan2 (BID_UINT128 * pres, BID_UINT128 * px, BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_fmod (BID_UINT128 * pres, BID_UINT128 * px, BID_UINT128 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_modf (BID_UINT128 * pres, BID_UINT128 * px, BID_UINT128 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_hypot (BID_UINT128 * pres, BID_UINT128 * px, BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_sin (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_cos (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_tan (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_asin (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_acos (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_atan (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_sinh (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_cosh (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_tanh (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_asinh (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_acosh (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_atanh (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_log1p (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_expm1 (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_log10 (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_log2 (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_exp2 (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_exp10 (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_erf (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_erfc (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_tgamma (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_lgamma (BID_UINT128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_add (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64dq_add (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qd_add (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qq_add (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_sub (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64dq_sub (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qd_sub (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qq_sub (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_mul (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64dq_mul (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qd_mul (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qq_mul (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_div (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64dq_div (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qd_div (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT64 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64qq_div (BID_UINT64 * pres, BID_UINT128 * px, + BID_UINT128 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_fma (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * py, + BID_UINT64 * + pz _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_sqrt (BID_UINT64 * pres, + BID_UINT64 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64q_sqrt (BID_UINT64 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_cbrt (BID_UINT64 * pres, + BID_UINT64 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_rnint (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_xrnint (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_rninta (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_xrninta (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_int (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_xint (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_floor (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_xfloor (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_ceil (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int8_xceil (char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_rnint (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_xrnint (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_rninta (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_xrninta (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_int (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_xint (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_floor (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_xfloor (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_ceil (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int16_xceil (short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_rnint (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_xrnint (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_rninta (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_xrninta (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_int (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_xint (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_floor (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_xfloor (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_ceil (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint8_xceil (unsigned char *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_rnint (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_xrnint (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_rninta (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_xrninta (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_int (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_xint (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_floor (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_xfloor (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_ceil (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint16_xceil (unsigned short *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_rnint (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_xrnint (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_rninta (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_xrninta (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_int (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_xint (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_floor (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_xfloor (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_ceil (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int32_xceil (int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_rnint (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_xrnint (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_rninta (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_xrninta (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_int (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_xint (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_floor (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_xfloor (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_ceil (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint32_xceil (unsigned int *pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_rnint (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_xrnint (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_rninta (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_xrninta (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_int (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_xint (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_floor (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_xfloor (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_ceil (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_int64_xceil (BID_SINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_rnint (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_xrnint (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_rninta (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_xrninta (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_int (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_xint (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_floor (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_xfloor (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_ceil (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_uint64_xceil (BID_UINT64 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_rnint (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_xrnint (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_rninta (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_xrninta (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_int (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_xint (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_floor (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_xfloor (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_ceil (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int32_xceil (int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_rnint (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_xrnint (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_rninta (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_xrninta (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_int (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_xint (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_floor (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_xfloor (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_ceil (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int8_xceil (char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_rnint (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_xrnint (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_rninta (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_xrninta (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_int (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_xint (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_floor (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_xfloor (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_ceil (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int16_xceil (short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_rnint (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_xrnint (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_rninta (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_xrninta (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_int (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_xint (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_floor (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_xfloor (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_ceil (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint8_xceil (unsigned char *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_rnint (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_xrnint (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_rninta (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_xrninta (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_int (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_xint (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_floor (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_xfloor (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_ceil (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint16_xceil (unsigned short *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_rnint (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_xrnint (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_rninta (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_xrninta (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_int (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_xint (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_floor (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_xfloor (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_ceil (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint32_xceil (unsigned int *pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_rnint (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_xrnint (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_rninta (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_xrninta (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_int (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_xint (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_floor (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_xfloor (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_ceil (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_int64_xceil (BID_SINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_rnint (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_xrnint (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_rninta (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_xrninta (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_int (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_xint (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_floor (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_xfloor (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_ceil (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_uint64_xceil (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_int32_rnint (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_xrnint (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_rninta (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_xrninta (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_int (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_xint (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_floor (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_xfloor (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_ceil (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int32_xceil (int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_rnint (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_xrnint (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_rninta (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_xrninta (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_int (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_xint (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_floor (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_xfloor (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_ceil (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int8_xceil (char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_rnint (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_xrnint (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_rninta (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_xrninta (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_int (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_xint (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_floor (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_xfloor (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_ceil (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int16_xceil (short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_rnint (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_xrnint (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_rninta (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_xrninta (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_int (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_xint (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_floor (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_xfloor (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_ceil (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint8_xceil (unsigned char *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_rnint (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_xrnint (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_rninta (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_xrninta (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_int (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_xint (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_floor (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_xfloor (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_ceil (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint16_xceil (unsigned short *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_rnint (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_xrnint (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_rninta (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_xrninta (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_int (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_xint (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_floor (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_xfloor (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_ceil (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint32_xceil (unsigned int *pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_rnint (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_xrnint (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_rninta (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_xrninta (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_int (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_xint (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_floor (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_xfloor (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_ceil (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_int64_xceil (BID_SINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_rnint (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_xrnint (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_rninta (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_xrninta (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_int (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_xint (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_floor (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_xfloor (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_ceil (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_uint64_xceil (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_quiet_equal (int *pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_greater (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_greater_equal (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_greater_unordered (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_less (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_less_equal (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_less_unordered (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_not_equal (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_not_greater (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_not_less (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_ordered (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quiet_unordered (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_greater (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_greater_equal (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_greater_unordered (int *pres, + BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_less (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_less_equal (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_less_unordered (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_not_greater (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_signaling_not_less (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_quiet_equal (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_greater (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_greater_equal (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_greater_unordered (int *pres, + BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_less (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_less_equal (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_less_unordered (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_not_equal (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_not_greater (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_not_less (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_ordered (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quiet_unordered (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_greater (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_greater_equal (int *pres, + BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_greater_unordered (int *pres, + BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_less (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_less_equal (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_less_unordered (int *pres, + BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_not_greater (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_signaling_not_less (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_round_integral_exact (BID_UINT32 * pres, BID_UINT32 * px + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_round_integral_nearest_even (BID_UINT32 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_round_integral_negative (BID_UINT32 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_round_integral_positive (BID_UINT32 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_round_integral_zero (BID_UINT32 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_round_integral_nearest_away (BID_UINT32 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_round_integral_exact (BID_UINT64 * pres, BID_UINT64 * px + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_round_integral_nearest_even (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_round_integral_negative (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_round_integral_positive (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_round_integral_zero (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_round_integral_nearest_away (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_round_integral_exact (BID_UINT128 * pres, + BID_UINT128 * + px _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_round_integral_nearest_even (BID_UINT128 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_round_integral_negative (BID_UINT128 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_round_integral_positive (BID_UINT128 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_round_integral_zero (BID_UINT128 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_round_integral_nearest_away (BID_UINT128 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_nextup (BID_UINT32 * pres, BID_UINT32 * px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_nextdown (BID_UINT32 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_nextafter (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_nextup (BID_UINT64 * pres, BID_UINT64 * px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_nextdown (BID_UINT64 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_nextafter (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_nextup (BID_UINT128 * pres, BID_UINT128 * px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_nextdown (BID_UINT128 * pres, + BID_UINT128 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_nextafter (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_minnum (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_minnum_mag (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_maxnum (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_maxnum_mag (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_minnum (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_minnum_mag (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_maxnum (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_maxnum_mag (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_minnum (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_minnum_mag (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_maxnum (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_maxnum_mag (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_from_int32 (BID_UINT32 * pres, int *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_from_uint32 (BID_UINT32 * pres, unsigned int *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_from_int64 (BID_UINT32 * pres, BID_SINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_from_uint64 (BID_UINT32 * pres, + BID_UINT64 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_from_int32 (BID_UINT64 * pres, int *px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_from_uint32 (BID_UINT64 * pres, unsigned int *px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_from_int64 (BID_UINT64 * pres, BID_SINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_from_uint64 (BID_UINT64 * pres, + BID_UINT64 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_from_int32 (BID_UINT128 * pres, + int *px _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_from_uint32 (BID_UINT128 * pres, + unsigned int *px _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_from_int64 (BID_UINT128 * pres, + BID_SINT64 * + px _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_from_uint64 (BID_UINT128 * pres, + BID_UINT64 * + px _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_isSigned (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isNormal (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isSubnormal (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isFinite (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isZero (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isInf (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isSignaling (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isCanonical (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_isNaN (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_copy (BID_UINT32 * pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_negate (BID_UINT32 * pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_abs (BID_UINT32 * pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_copySign (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_class (int *pres, BID_UINT32 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_sameQuantum (int *pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_totalOrder (int *pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_totalOrderMag (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_radix (int *pres, + BID_UINT32 * + px _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_isSigned (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isNormal (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isSubnormal (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isFinite (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isZero (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isInf (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isSignaling (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isCanonical (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_isNaN (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_copy (BID_UINT64 * pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_negate (BID_UINT64 * pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_abs (BID_UINT64 * pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_copySign (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_class (int *pres, BID_UINT64 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_sameQuantum (int *pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_totalOrder (int *pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_totalOrderMag (int *pres, BID_UINT64 * px, + BID_UINT64 * + py _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_radix (int *pres, + BID_UINT64 * + px _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_isSigned (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isNormal (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isSubnormal (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isFinite (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isZero (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isInf (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isSignaling (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isCanonical (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_isNaN (int *pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_copy (BID_UINT128 * pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_negate (BID_UINT128 * pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_abs (BID_UINT128 * pres, BID_UINT128 * px + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_copySign (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_class (int *pres, + BID_UINT128 * + px _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_sameQuantum (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_totalOrder (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_totalOrderMag (int *pres, BID_UINT128 * px, + BID_UINT128 * + py _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_radix (int *pres, + BID_UINT128 * + px _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_rem (BID_UINT32 * pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_ilogb (int * pres, BID_UINT32 * px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_scalbn (BID_UINT32 * pres, BID_UINT32 * px, + int *pn _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_ldexp (BID_UINT32 * pres, BID_UINT32 * px, + int *pn _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_rem (BID_UINT64 * pres, BID_UINT64 * px, BID_UINT64 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_ilogb (int * pres, BID_UINT64 * px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_scalbn (BID_UINT64 * pres, BID_UINT64 * px, + int *pn _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_ldexp (BID_UINT64 * pres, BID_UINT64 * px, + int *pn _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_rem (BID_UINT128 * pres, BID_UINT128 * px, BID_UINT128 * py + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_ilogb (int * pres, BID_UINT128 * px + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_scalbn (BID_UINT128 * pres, BID_UINT128 * px, + int *pn _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_ldexp (BID_UINT128 * pres, BID_UINT128 * px, + int *pn _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_bid64 (BID_UINT64 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_bid128 (BID_UINT128 * pres, + BID_UINT32 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_bid128 (BID_UINT128 * pres, + BID_UINT64 * + px _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_bid32 (BID_UINT32 * pres, + BID_UINT64 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_bid32 (BID_UINT32 * pres, + BID_UINT128 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_bid64 (BID_UINT64 * pres, + BID_UINT128 * + px _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_from_string (BID_UINT32 * pres, char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_to_string (char *ps, BID_UINT32 * px + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_from_string (BID_UINT64 * pres, char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_string (char *ps, BID_UINT64 * px + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_from_string (BID_UINT128 * pres, char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_string (char *str, BID_UINT128 * px + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_quantize (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_quantize (BID_UINT64 * pres, BID_UINT64 * px, + BID_UINT64 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_quantize (BID_UINT128 * pres, BID_UINT128 * px, + BID_UINT128 * + py _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_to_binary32 (float *pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_to_binary64 (double *pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_to_binary80 (BINARY80 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid128_to_binary128 (BINARY128 * pres, BID_UINT128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary128_to_bid32 (BID_UINT32 * pres, BINARY128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary128_to_bid64 (BID_UINT64 * pres, BINARY128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary128_to_bid128 (BID_UINT128 * pres, BINARY128 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_to_binary32 (float *pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_to_binary64 (double *pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_to_binary80 (BINARY80 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid64_to_binary128 (BINARY128 * pres, BID_UINT64 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary64_to_bid32 (BID_UINT32 * pres, double *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary64_to_bid64 (BID_UINT64 * pres, double *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary64_to_bid128 (BID_UINT128 * pres, double *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_binary32 (float *pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_binary64 (double *pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_binary80 (BINARY80 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_binary128 (BINARY128 * pres, BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary32_to_bid32 (BID_UINT32 * pres, float *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary32_to_bid64 (BID_UINT64 * pres, float *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary32_to_bid128 (BID_UINT128 * pres, float *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary80_to_bid32 (BID_UINT32 * pres, BINARY80 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary80_to_bid64 (BID_UINT64 * pres, BINARY80 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void binary80_to_bid128 (BID_UINT128 * pres, BINARY80 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid_is754 (int *retval); + + BID_EXTERN_C void bid_is754R (int *retval); + + BID_EXTERN_C void bid_signalException (_IDEC_flags * + pflagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C void bid_lowerFlags (_IDEC_flags * pflagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C void bid_testFlags (_IDEC_flags * praised, + _IDEC_flags * pflagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C void bid_testSavedFlags (_IDEC_flags * praised, + _IDEC_flags * psavedflags, + _IDEC_flags * pflagsmask); + + BID_EXTERN_C void bid_restoreFlags (_IDEC_flags * pflagsvalues, + _IDEC_flags * + pflagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C void bid_saveFlags (_IDEC_flags * pflagsvalues, + _IDEC_flags * pflagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C void bid_getDecimalRoundingDirection (_IDEC_round * + rounding_mode _RND_MODE_PARAM); + + BID_EXTERN_C void bid_setDecimalRoundingDirection (_IDEC_round * + rounding_mode _RND_MODE_PARAM); + + BID_EXTERN_C void bid32_add (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_sub (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_mul (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_div (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_fma (BID_UINT32 * pres, BID_UINT32 * px, + BID_UINT32 * py, BID_UINT32 * pz + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_sqrt (BID_UINT32 * pres, + BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_cbrt (BID_UINT32 * pres, + BID_UINT32 * px + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_equal (int *pres, BID_UINT32 * px, BID_UINT32 * py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_greater (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_greater_equal (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_greater_unordered (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_less (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_less_equal (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_less_unordered (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_not_equal (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_not_greater (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_not_less (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_ordered (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quiet_unordered (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_greater (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_greater_equal (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_greater_unordered (int *pres, + BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_less (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_less_equal (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_less_unordered (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_not_greater (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_signaling_not_less (int *pres, BID_UINT32 * px, + BID_UINT32 * + py _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_frexp (BID_UINT32 *pres, BID_UINT32 *px, int *exp); + BID_EXTERN_C void bid64_frexp (BID_UINT64 *pres, BID_UINT64 *px, int *exp); + BID_EXTERN_C void bid128_frexp (BID_UINT128 *pres, BID_UINT128 *px, int *exp); + BID_EXTERN_C void bid32_logb (BID_UINT32 *pres, BID_UINT32 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_logb (BID_UINT64 *pres, BID_UINT64 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_logb (BID_UINT128 *pres, BID_UINT128 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_scalbln (BID_UINT32 *pres, BID_UINT32 *px, long int *pn + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_scalbln (BID_UINT64 *pres, BID_UINT64 *px, long int *pn + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_scalbln (BID_UINT128 *pres, BID_UINT128 *px, long int *pn + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_nearbyint (BID_UINT32 *pres, BID_UINT32 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_nearbyint (BID_UINT64 *pres, BID_UINT64 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_nearbyint (BID_UINT128 *pres, BID_UINT128 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_lrint (long int *pres, BID_UINT32 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_lrint (long int *pres, BID_UINT64 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_lrint (long int *pres, BID_UINT128 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_llrint (long long int *pres, BID_UINT32 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_llrint (long long int *pres, BID_UINT64 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_llrint (long long int *pres, BID_UINT128 *px + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_lround (long int *pres, BID_UINT32 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_lround (long int *pres, BID_UINT64 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_lround (long int *pres, BID_UINT128 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_llround (long long int *pres, BID_UINT32 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_llround (long long int *pres, BID_UINT64 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_llround (long long int *pres, BID_UINT128 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_nan (BID_UINT32 *pres, const char *tagp); + BID_EXTERN_C void bid64_nan (BID_UINT64 *pres, const char *tagp); + BID_EXTERN_C void bid128_nan (BID_UINT128 *pres, const char *tagp); + BID_EXTERN_C void bid32_nexttoward (BID_UINT32 *pres, BID_UINT32 *px, BID_UINT128 *py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_nexttoward (BID_UINT64 *pres, BID_UINT64 *px, BID_UINT128 *py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_nexttoward (BID_UINT128 *pres, BID_UINT128 *px, BID_UINT128 *py + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_fdim (BID_UINT32 *pres, BID_UINT32 *px, BID_UINT32 *py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_fdim (BID_UINT64 *pres, BID_UINT64 *px, BID_UINT64 *py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_fdim (BID_UINT128 *pres, BID_UINT128 *px, BID_UINT128 *py + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_quantexp (int *pres, BID_UINT32 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quantexp (int *pres, BID_UINT64 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quantexp (int *pres, BID_UINT128 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_quantum (BID_UINT32 *pres, BID_UINT32 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_quantum (BID_UINT64 *pres, BID_UINT64 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_quantum (BID_UINT128 *pres, BID_UINT128 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid32_llquantexp (long long int *pres, BID_UINT32 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_llquantexp (long long int *pres, BID_UINT64 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_llquantexp (long long int *pres, BID_UINT128 *px + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_inf (BID_UINT32 *pres); + BID_EXTERN_C void bid64_inf (BID_UINT64 *pres); + BID_EXTERN_C void bid128_inf (BID_UINT128 *pres); + +#else + + BID_EXTERN_C BID_UINT32 bid_to_dpd32 (BID_UINT32 px); + BID_EXTERN_C BID_UINT64 bid_to_dpd64 (BID_UINT64 px); + BID_EXTERN_C BID_UINT128 bid_to_dpd128 (BID_UINT128 px); + BID_EXTERN_C BID_UINT32 bid_dpd_to_bid32 (BID_UINT32 px); + BID_EXTERN_C BID_UINT64 bid_dpd_to_bid64 (BID_UINT64 px); + BID_EXTERN_C BID_UINT128 bid_dpd_to_bid128 (BID_UINT128 px); + + BID_EXTERN_C BID_UINT128 bid128dd_add (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dq_add (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qd_add (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_add (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dd_sub (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dq_sub (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qd_sub (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_sub (BID_UINT128 x, + BID_UINT128 y _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dd_mul (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dq_mul (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qd_mul (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_mul (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_div (BID_UINT128 x, + BID_UINT128 y _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dd_div (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dq_div (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qd_div (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_fma (BID_UINT128 x, BID_UINT128 y, BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128ddd_fma (BID_UINT64 x, BID_UINT64 y, BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128ddq_fma (BID_UINT64 x, BID_UINT64 y, BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dqd_fma (BID_UINT64 x, BID_UINT128 y, BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128dqq_fma (BID_UINT64 x, BID_UINT128 y, + BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qdd_fma (BID_UINT128 x, BID_UINT64 y, BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qdq_fma (BID_UINT128 x, BID_UINT64 y, + BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128qqd_fma (BID_UINT128 x, BID_UINT128 y, + BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + // Note: bid128qqq_fma is represented by bid128_fma + // Note: bid64ddd_fma is represented by bid64_fma + BID_EXTERN_C BID_UINT64 bid64ddq_fma (BID_UINT64 x, BID_UINT64 y, + BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64dqd_fma (BID_UINT64 x, BID_UINT128 y, + BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64dqq_fma (BID_UINT64 x, BID_UINT128 y, + BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qdd_fma (BID_UINT128 x, BID_UINT64 y, + BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qdq_fma (BID_UINT128 x, BID_UINT64 y, + BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qqd_fma (BID_UINT128 x, BID_UINT128 y, + BID_UINT64 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qqq_fma (BID_UINT128 x, BID_UINT128 y, + BID_UINT128 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_sqrt (BID_UINT128 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128d_sqrt (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_cbrt (BID_UINT128 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_exp (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_log (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_pow (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_atan2 (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_fmod (BID_UINT32 x, BID_UINT32 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_modf (BID_UINT32 x, BID_UINT32 * y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_hypot (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_sin (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_cos (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_tan (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_asin (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_acos (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_atan (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_sinh (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_cosh (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_tanh (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_asinh (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_acosh (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_atanh (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_log1p (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_expm1 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_log10 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_log2 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_exp2 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_exp10 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_erf (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_erfc (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_tgamma (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_lgamma (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_exp (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_log (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_pow (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_atan2 (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_fmod (BID_UINT64 x, BID_UINT64 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_modf (BID_UINT64 x, BID_UINT64 * y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_hypot (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_sin (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_cos (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_tan (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_asin (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_acos (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_atan (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_sinh (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_cosh (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_tanh (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_asinh (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_acosh (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_atanh (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_log1p (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_expm1 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_log10 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_log2 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_exp2 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_exp10 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_erf (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_erfc (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_tgamma (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_lgamma (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_exp (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_log (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_pow (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_atan2 (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_fmod (BID_UINT128 x, BID_UINT128 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_modf (BID_UINT128 x, BID_UINT128 * y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_hypot (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_sin (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_cos (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_tan (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_asin (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_acos (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_atan (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_sinh (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_cosh (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_tanh (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_asinh (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_acosh (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_atanh (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_log1p (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_expm1 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_log10 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_log2 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_exp2 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_exp10 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_erf (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_erfc (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_tgamma (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_lgamma (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_add (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64dq_add (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qd_add (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qq_add (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_sub (BID_UINT64 x, + BID_UINT64 y _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64dq_sub (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qd_sub (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qq_sub (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_mul (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64dq_mul (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qd_mul (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qq_mul (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_div (BID_UINT64 x, + BID_UINT64 y _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64dq_div (BID_UINT64 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qd_div (BID_UINT128 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64qq_div (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_fma (BID_UINT64 x, BID_UINT64 y, + BID_UINT64 z _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_sqrt (BID_UINT64 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64q_sqrt (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_cbrt (BID_UINT64 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_rnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_xrnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_rninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_xrninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_int (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_xint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_floor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_xfloor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_ceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid128_to_int8_xceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_rnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_xrnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_rninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_xrninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_int (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_xint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_floor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_xfloor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_ceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid128_to_int16_xceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_rnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_xrnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_rninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_xrninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_int (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_xint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_floor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_xfloor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_ceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid128_to_uint8_xceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_rnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_xrnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_rninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_xrninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_int (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_xint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_floor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_xfloor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_ceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid128_to_uint16_xceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_rnint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_xrnint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_rninta (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_xrninta (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_int (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_xint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_floor (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_xfloor (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_ceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_to_int32_xceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_rnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_xrnint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_rninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_xrninta (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_int (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_xint (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_floor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_xfloor (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_ceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid128_to_uint32_xceil (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_rnint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_xrnint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_rninta (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_xrninta (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_int (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_xint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_floor (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_xfloor (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_ceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid128_to_int64_xceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_rnint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_xrnint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_rninta (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_xrninta (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_int (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_xint (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_floor (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_xfloor (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_ceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_uint64_xceil (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_rnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_xrnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_rninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_xrninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_floor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_xfloor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_to_int32_xceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_rnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_xrnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_rninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_xrninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_floor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_xfloor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid64_to_int8_xceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_rnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_xrnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_rninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_xrninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_floor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_xfloor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid64_to_int16_xceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_rnint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_xrnint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_rninta (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_xrninta (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_floor (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_xfloor (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid64_to_uint8_xceil (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_rnint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_xrnint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_rninta (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_xrninta (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_int (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_xint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_floor (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_xfloor (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_ceil (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid64_to_uint16_xceil (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_rnint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_xrnint (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_rninta (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_xrninta (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_floor (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_xfloor (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid64_to_uint32_xceil (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_rnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_xrnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_rninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_xrninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_floor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_xfloor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid64_to_int64_xceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_rnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_xrnint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_rninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_xrninta (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_int (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_xint (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_floor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_xfloor (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_ceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_to_uint64_xceil (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C char bid32_to_int8_rnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_xrnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_rninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_xrninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_int (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_xint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_floor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_xfloor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_ceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C char bid32_to_int8_xceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_rnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_xrnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_rninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_xrninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_int (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_xint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_floor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_xfloor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_ceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C short bid32_to_int16_xceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_rnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_xrnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_rninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_xrninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_int (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_xint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_floor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_xfloor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_ceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned char bid32_to_uint8_xceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_rnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_xrnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_rninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_xrninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_int (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_xint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_floor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_xfloor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_ceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned short bid32_to_uint16_xceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_rnint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_xrnint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_rninta (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_xrninta (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_int (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_xint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_floor (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_xfloor (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_ceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_to_int32_xceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_rnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_xrnint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_rninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_xrninta (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_int (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_xint (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_floor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_xfloor (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_ceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C unsigned int bid32_to_uint32_xceil (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_rnint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_xrnint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_rninta (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_xrninta (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_int (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_xint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_floor (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_xfloor (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_ceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_SINT64 bid32_to_int64_xceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_rnint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_xrnint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_rninta (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_xrninta (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_int (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_xint (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_floor (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_xfloor (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_ceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid32_to_uint64_xceil (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C int bid64_quiet_equal (BID_UINT64 x, BID_UINT64 y + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_greater (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_greater_equal (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_greater_unordered (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_less (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_less_equal (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_less_unordered (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_not_equal (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_not_greater (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_not_less (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_ordered (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quiet_unordered (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_greater (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_greater_equal (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_greater_unordered (BID_UINT64 x, + BID_UINT64 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_less (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_less_equal (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_less_unordered (BID_UINT64 x, + BID_UINT64 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_not_greater (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_signaling_not_less (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C int bid128_quiet_equal (BID_UINT128 x, BID_UINT128 y + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_greater (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_greater_equal (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_greater_unordered (BID_UINT128 x, + BID_UINT128 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_less (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_less_equal (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_less_unordered (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_not_equal (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_not_greater (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_not_less (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_ordered (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quiet_unordered (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_greater (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_greater_equal (BID_UINT128 x, + BID_UINT128 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_greater_unordered (BID_UINT128 x, + BID_UINT128 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_less (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_less_equal (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_less_unordered (BID_UINT128 x, + BID_UINT128 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_not_greater (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_signaling_not_less (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C int bid32_quiet_equal (BID_UINT32 x, BID_UINT32 y + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_greater_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_greater_unordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_less_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_less_unordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_not_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_not_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_not_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_ordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_unordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_greater_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_greater_unordered (BID_UINT32 x, + BID_UINT32 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_less_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_less_unordered (BID_UINT32 x, + BID_UINT32 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_not_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_not_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_round_integral_exact (BID_UINT32 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_round_integral_nearest_even (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_round_integral_negative (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_round_integral_positive (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_round_integral_zero (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_round_integral_nearest_away (BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_round_integral_exact (BID_UINT64 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_round_integral_nearest_even (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_round_integral_negative (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_round_integral_positive (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_round_integral_zero (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_round_integral_nearest_away (BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_round_integral_exact (BID_UINT128 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_round_integral_nearest_even (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_round_integral_negative (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_round_integral_positive (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_round_integral_zero (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_round_integral_nearest_away (BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_nextup (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_nextdown (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_nextafter (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_nextup (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_nextdown (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_nextafter (BID_UINT64 x, + BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_nextup (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_nextdown (BID_UINT128 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_nextafter (BID_UINT128 x, + BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_minnum (BID_UINT32 x, BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_minnum_mag (BID_UINT32 x, BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_maxnum (BID_UINT32 x, BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_maxnum_mag (BID_UINT32 x, BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_minnum (BID_UINT64 x, BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_minnum_mag (BID_UINT64 x, BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_maxnum (BID_UINT64 x, BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_maxnum_mag (BID_UINT64 x, BID_UINT64 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_minnum (BID_UINT128 x, BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_minnum_mag (BID_UINT128 x, BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_maxnum (BID_UINT128 x, BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_maxnum_mag (BID_UINT128 x, BID_UINT128 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_from_int32 (int x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_from_uint32 (unsigned int x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_from_int64 (BID_SINT64 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_from_uint64 (BID_UINT64 _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_from_int32 (int x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_from_uint32 (unsigned int x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_from_int64 (BID_SINT64 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_from_uint64 (BID_UINT64 _RND_MODE_PARAM + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_from_int32 (int x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_from_uint32 (unsigned int x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_from_int64 (BID_SINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_from_uint64 (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C int bid32_isSigned (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isNormal (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isSubnormal (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isFinite (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isZero (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isInf (BID_UINT32 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isSignaling (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isCanonical (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_isNaN (BID_UINT32 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_copy (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_negate (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_abs (BID_UINT32 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_copySign (BID_UINT32 x, + BID_UINT32 y _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C class_t bid32_class (BID_UINT32 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_sameQuantum (BID_UINT32 x, BID_UINT32 y + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_totalOrder (BID_UINT32 x, BID_UINT32 y + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_totalOrderMag (BID_UINT32 x, BID_UINT32 y + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_radix (BID_UINT32 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C int bid64_isSigned (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isNormal (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isSubnormal (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isFinite (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isZero (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isInf (BID_UINT64 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isSignaling (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isCanonical (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_isNaN (BID_UINT64 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_copy (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_negate (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_abs (BID_UINT64 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_copySign (BID_UINT64 x, + BID_UINT64 y _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C class_t bid64_class (BID_UINT64 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_sameQuantum (BID_UINT64 x, BID_UINT64 y + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_totalOrder (BID_UINT64 x, BID_UINT64 y + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_totalOrderMag (BID_UINT64 x, BID_UINT64 y + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_radix (BID_UINT64 x _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C int bid128_isSigned (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isNormal (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isSubnormal (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isFinite (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isZero (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isInf (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isSignaling (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isCanonical (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_isNaN (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_copy (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_negate (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_abs (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_copySign (BID_UINT128 x, + BID_UINT128 y _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C class_t bid128_class (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_sameQuantum (BID_UINT128 x, + BID_UINT128 y _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_totalOrder (BID_UINT128 x, + BID_UINT128 y _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_totalOrderMag (BID_UINT128 x, + BID_UINT128 y _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_radix (BID_UINT128 x _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_rem (BID_UINT32 x, BID_UINT32 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_ilogb (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_scalbn (BID_UINT32 x, + int n _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_ldexp (BID_UINT32 x, + int n _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_rem (BID_UINT64 x, BID_UINT64 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_ilogb (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_scalbn (BID_UINT64 x, + int n _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_ldexp (BID_UINT64 x, + int n _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_rem (BID_UINT128 x, BID_UINT128 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_ilogb (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_scalbn (BID_UINT128 x, + int n _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_ldexp (BID_UINT128 x, + int n _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid32_to_bid64 (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid32_to_bid128 (BID_UINT32 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid64_to_bid128 (BID_UINT64 x _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid64_to_bid32 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid128_to_bid32 (BID_UINT128 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid128_to_bid64 (BID_UINT128 x _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C void bid32_to_string (char *ps, BID_UINT32 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_from_string (char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid64_to_string (char *ps, BID_UINT64 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_from_string (char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C void bid128_to_string (char *str, BID_UINT128 x + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_from_string (char *ps + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_quantize (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 bid64_quantize (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 bid128_quantize (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + + BID_EXTERN_C BID_UINT32 binary128_to_bid32 (BINARY128 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 binary128_to_bid64 (BINARY128 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 binary128_to_bid128 (BINARY128 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 binary64_to_bid32 (double x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 binary64_to_bid64 (double x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 binary64_to_bid128 (double x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 binary80_to_bid32 (BINARY80 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 binary80_to_bid64 (BINARY80 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 binary80_to_bid128 (BINARY80 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 binary32_to_bid32 (float x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT64 binary32_to_bid64 (float x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT128 binary32_to_bid128 (float x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C float bid128_to_binary32 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C double bid128_to_binary64 (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BINARY80 bid128_to_binary80 (BID_UINT128 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BINARY128 bid128_to_binary128 (BID_UINT128 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C float bid64_to_binary32 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C double bid64_to_binary64 (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BINARY80 bid64_to_binary80 (BID_UINT64 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BINARY128 bid64_to_binary128 (BID_UINT64 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C float bid32_to_binary32 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C double bid32_to_binary64 (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BINARY80 bid32_to_binary80 (BID_UINT32 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BINARY128 bid32_to_binary128 (BID_UINT32 x + _RND_MODE_PARAM + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C int bid_is754 (void); + + BID_EXTERN_C int bid_is754R (void); + + BID_EXTERN_C void bid_signalException (_IDEC_flags flagsmask + _EXC_FLAGS_PARAM); + + BID_EXTERN_C void bid_lowerFlags (_IDEC_flags flagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C _IDEC_flags bid_testFlags (_IDEC_flags flagsmask + _EXC_FLAGS_PARAM); + + BID_EXTERN_C _IDEC_flags bid_testSavedFlags (_IDEC_flags savedflags, + _IDEC_flags flagsmask); + + BID_EXTERN_C void bid_restoreFlags (_IDEC_flags flagsvalues, + _IDEC_flags flagsmask _EXC_FLAGS_PARAM); + + BID_EXTERN_C _IDEC_flags bid_saveFlags (_IDEC_flags flagsmask + _EXC_FLAGS_PARAM); + +#if !DECIMAL_GLOBAL_ROUNDING + BID_EXTERN_C _IDEC_round bid_getDecimalRoundingDirection (_IDEC_round rnd_mode); +#else + BID_EXTERN_C _IDEC_round bid_getDecimalRoundingDirection (void); +#endif + +#if !DECIMAL_GLOBAL_ROUNDING + BID_EXTERN_C _IDEC_round bid_setDecimalRoundingDirection (_IDEC_round + rounding_mode + _RND_MODE_PARAM); +#else + BID_EXTERN_C void bid_setDecimalRoundingDirection (_IDEC_round rounding_mode); +#endif + + BID_EXTERN_C BID_UINT32 bid32_add (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_sub (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_mul (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_div (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_fma (BID_UINT32 x, BID_UINT32 y, BID_UINT32 z + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_sqrt (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_cbrt (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_greater_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_greater_unordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_less_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_less_unordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_not_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_not_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_not_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_ordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quiet_unordered (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_greater_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_greater_unordered (BID_UINT32 x, + BID_UINT32 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_less_equal (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_less_unordered (BID_UINT32 x, + BID_UINT32 y + _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_not_greater (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_signaling_not_less (BID_UINT32 x, + BID_UINT32 y _EXC_FLAGS_PARAM + _EXC_MASKS_PARAM + _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_frexp (BID_UINT32 x, int *exp); + BID_EXTERN_C BID_UINT64 bid64_frexp (BID_UINT64 x, int *exp); + BID_EXTERN_C BID_UINT128 bid128_frexp (BID_UINT128 x, int *exp); + BID_EXTERN_C BID_UINT32 bid32_logb (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_logb (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_logb (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_scalbln (BID_UINT32 x, long int n + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_scalbln (BID_UINT64 x, long int n + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_scalbln (BID_UINT128 x, long int n + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_nearbyint (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_nearbyint (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_nearbyint (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long int bid32_lrint (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long int bid64_lrint (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long int bid128_lrint (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid32_llrint (BID_UINT32 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid64_llrint (BID_UINT64 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid128_llrint (BID_UINT128 x + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long int bid32_lround (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long int bid64_lround (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long int bid128_lround (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid32_llround (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid64_llround (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid128_llround (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_nan (const char *tagp); + BID_EXTERN_C BID_UINT64 bid64_nan (const char *tagp); + BID_EXTERN_C BID_UINT128 bid128_nan (const char *tagp); + BID_EXTERN_C BID_UINT32 bid32_nexttoward (BID_UINT32 x, BID_UINT128 y + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_nexttoward (BID_UINT64 x, BID_UINT128 y + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_nexttoward (BID_UINT128 x, BID_UINT128 y + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT32 bid32_fdim (BID_UINT32 x, BID_UINT32 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_fdim (BID_UINT64 x, BID_UINT64 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_fdim (BID_UINT128 x, BID_UINT128 y + _RND_MODE_PARAM _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid32_quantexp (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid64_quantexp (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C int bid128_quantexp (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_quantum (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT64 bid64_quantum (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C BID_UINT128 bid128_quantum (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid32_llquantexp (BID_UINT32 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid64_llquantexp (BID_UINT64 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + BID_EXTERN_C long long int bid128_llquantexp (BID_UINT128 x + _EXC_FLAGS_PARAM _EXC_MASKS_PARAM _EXC_INFO_PARAM); + + BID_EXTERN_C BID_UINT32 bid32_inf (void); + BID_EXTERN_C BID_UINT64 bid64_inf (void); + BID_EXTERN_C BID_UINT128 bid128_inf (void); + +#endif + +// Functions not dependent on different parameters +BID_EXTERN_C BID_UINT32 bid_strtod32(const char* ps_in, char** endptr); +BID_EXTERN_C BID_UINT64 bid_strtod64(const char* ps_in, char** endptr); +BID_EXTERN_C BID_UINT128 bid_strtod128(const char* ps_in, char** endptr); +BID_EXTERN_C BID_UINT32 bid_wcstod32(const wchar_t* ps_in, wchar_t** endptr); +BID_EXTERN_C BID_UINT64 bid_wcstod64(const wchar_t* ps_in, wchar_t** endptr); +BID_EXTERN_C BID_UINT128 bid_wcstod128(const wchar_t* ps_in, wchar_t** endptr); +BID_EXTERN_C void bid_feclearexcept( int excepts _EXC_FLAGS_PARAM ); +BID_EXTERN_C void bid_fegetexceptflag( fexcept_t *flagp, int excepts _EXC_FLAGS_PARAM ); +BID_EXTERN_C void bid_feraiseexcept( int excepts _EXC_FLAGS_PARAM ); +BID_EXTERN_C void bid_fesetexceptflag( const fexcept_t *flagp, int excepts _EXC_FLAGS_PARAM ); +BID_EXTERN_C int bid_fetestexcept( int excepts _EXC_FLAGS_PARAM ); + +// Internal Functions + + BID_EXTERN_C void + bid_round64_2_18 (int q, + int x, + BID_UINT64 C, + BID_UINT64 * ptr_Cstar, + int *delta_exp, + int *ptr_is_midpoint_lt_even, + int *ptr_is_midpoint_gt_even, + int *ptr_is_inexact_lt_midpoint, + int *ptr_is_inexact_gt_midpoint); + + BID_EXTERN_C void + bid_round128_19_38 (int q, + int x, + BID_UINT128 C, + BID_UINT128 * ptr_Cstar, + int *delta_exp, + int *ptr_is_midpoint_lt_even, + int *ptr_is_midpoint_gt_even, + int *ptr_is_inexact_lt_midpoint, + int *ptr_is_inexact_gt_midpoint); + + BID_EXTERN_C void + bid_round192_39_57 (int q, + int x, + BID_UINT192 C, + BID_UINT192 * ptr_Cstar, + int *delta_exp, + int *ptr_is_midpoint_lt_even, + int *ptr_is_midpoint_gt_even, + int *ptr_is_inexact_lt_midpoint, + int *ptr_is_inexact_gt_midpoint); + + BID_EXTERN_C void + bid_round256_58_76 (int q, + int x, + BID_UINT256 C, + BID_UINT256 * ptr_Cstar, + int *delta_exp, + int *ptr_is_midpoint_lt_even, + int *ptr_is_midpoint_gt_even, + int *ptr_is_inexact_lt_midpoint, + int *ptr_is_inexact_gt_midpoint); + +#endif + diff --git a/reftest/bid_gcc_intrinsics.h b/reftest/bid_gcc_intrinsics.h new file mode 100644 index 0000000..b70ab84 --- /dev/null +++ b/reftest/bid_gcc_intrinsics.h @@ -0,0 +1,301 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +#ifndef _BID_GCC_INTRINSICS_H +#define _BID_GCC_INTRINSICS_H + +#ifdef IN_LIBGCC2 + +#include "tconfig.h" +#include "coretypes.h" +#include "tm.h" + +#ifndef LIBGCC2_WORDS_BIG_ENDIAN +#define LIBGCC2_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN +#endif + +#ifndef LIBGCC2_FLOAT_WORDS_BIG_ENDIAN +#define LIBGCC2_FLOAT_WORDS_BIG_ENDIAN LIBGCC2_WORDS_BIG_ENDIAN +#endif + +#ifndef LIBGCC2_LONG_DOUBLE_TYPE_SIZE +#define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE +#endif + +#ifndef LIBGCC2_HAS_XF_MODE +#define LIBGCC2_HAS_XF_MODE \ + (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 80) +#endif + +#ifndef LIBGCC2_HAS_TF_MODE +#define LIBGCC2_HAS_TF_MODE \ + (BITS_PER_UNIT == 8 && LIBGCC2_LONG_DOUBLE_TYPE_SIZE == 128) +#endif + +#ifndef BID_HAS_XF_MODE +#define BID_HAS_XF_MODE LIBGCC2_HAS_XF_MODE +#endif + +#ifndef BID_HAS_TF_MODE +#define BID_HAS_TF_MODE LIBGCC2_HAS_TF_MODE +#endif + +/* Some handy typedefs. */ + +typedef float SFtype __attribute__ ((mode (SF))); +typedef float DFtype __attribute__ ((mode (DF))); +#if LIBGCC2_HAS_XF_MODE +typedef float XFtype __attribute__ ((mode (XF))); +#endif /* LIBGCC2_HAS_XF_MODE */ +#if LIBGCC2_HAS_TF_MODE +typedef float TFtype __attribute__ ((mode (TF))); +#endif /* LIBGCC2_HAS_XF_MODE */ + +typedef int SItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); + +/* The type of the result of a decimal float comparison. This must + match `word_mode' in GCC for the target. */ + +typedef int CMPtype __attribute__ ((mode (word))); + +typedef int BID_SINT8 __attribute__ ((mode (QI))); +typedef unsigned int BID_UINT8 __attribute__ ((mode (QI))); +typedef USItype BID_UINT32; +typedef SItype BID_SINT32; +typedef UDItype BID_UINT64; +typedef DItype BID_SINT64; + +/* It has to be identical to the one defined in bid_functions.h. */ +typedef __attribute__ ((aligned(16))) struct +{ + BID_UINT64 w[2]; +} BID_UINT128; +#else /* if not IN_LIBGCC2 */ + +#ifndef BID_HAS_XF_MODE +#define BID_HAS_XF_MODE 1 +#endif + +#ifndef BID_HAS_TF_MODE +#if defined __i386__ +#define BID_HAS_TF_MODE 0 +#else +#define BID_HAS_TF_MODE 1 +#endif +#endif + +#ifndef SFtype +#define SFtype float +#endif + +#ifndef DFtype +#define DFtype double +#endif + +#if BID_HAS_XF_MODE +#ifndef XFtype +#define XFtype long double +#endif + +#endif /* IN_LIBGCC2 */ + +#if BID_HAS_TF_MODE +#ifndef TFtype +#define TFtype __float128 +#endif +#endif + +#ifndef SItype +#define SItype BID_SINT32 +#endif + +#ifndef DItype +#define DItype BID_SINT64 +#endif + +#ifndef USItype +#define USItype BID_UINT32 +#endif + +#ifndef UDItype +#define UDItype BID_UINT64 +#endif + +#ifndef CMPtype +#define CMPtype long +#endif +#endif /* IN_LIBGCC2 */ + +#if BID_HAS_GCC_DECIMAL_INTRINSICS +/* Prototypes for gcc instrinsics */ + +BID_EXTERN_C _Decimal64 __bid_adddd3 (_Decimal64, _Decimal64); +BID_EXTERN_C _Decimal64 __bid_subdd3 (_Decimal64, _Decimal64); +BID_EXTERN_C _Decimal32 __bid_addsd3 (_Decimal32, _Decimal32); +BID_EXTERN_C _Decimal32 __bid_subsd3 (_Decimal32, _Decimal32); +BID_EXTERN_C _Decimal128 __bid_addtd3 (_Decimal128, _Decimal128); +BID_EXTERN_C _Decimal128 __bid_subtd3 (_Decimal128, _Decimal128); +BID_EXTERN_C DFtype __bid_truncdddf (_Decimal64); +BID_EXTERN_C DItype __bid_fixdddi (_Decimal64); +BID_EXTERN_C _Decimal32 __bid_truncddsd2 (_Decimal64); +BID_EXTERN_C SFtype __bid_truncddsf (_Decimal64); +BID_EXTERN_C SItype __bid_fixddsi (_Decimal64); +BID_EXTERN_C _Decimal128 __bid_extendddtd2 (_Decimal64); +#if BID_HAS_TF_MODE +BID_EXTERN_C TFtype __bid_extendddtf (_Decimal64); +#endif +BID_EXTERN_C UDItype __bid_fixunsdddi (_Decimal64); +BID_EXTERN_C USItype __bid_fixunsddsi (_Decimal64); +#if BID_HAS_XF_MODE +BID_EXTERN_C XFtype __bid_extendddxf (_Decimal64); +#endif +BID_EXTERN_C _Decimal64 __bid_extenddfdd (DFtype); +BID_EXTERN_C _Decimal32 __bid_truncdfsd (DFtype); +BID_EXTERN_C _Decimal128 __bid_extenddftd (DFtype); +BID_EXTERN_C _Decimal64 __bid_floatdidd (DItype); +BID_EXTERN_C _Decimal32 __bid_floatdisd (DItype); +BID_EXTERN_C _Decimal128 __bid_floatditd (DItype); +BID_EXTERN_C _Decimal64 __bid_divdd3 (_Decimal64, _Decimal64); +BID_EXTERN_C _Decimal32 __bid_divsd3 (_Decimal32, _Decimal32); +BID_EXTERN_C _Decimal128 __bid_divtd3 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_eqdd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_eqsd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_eqtd2 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_gedd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_gesd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_getd2 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_gtdd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_gtsd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_gttd2 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_ledd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_lesd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_letd2 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_ltdd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_ltsd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_lttd2 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_nedd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_nesd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_netd2 (_Decimal128, _Decimal128); +BID_EXTERN_C CMPtype __bid_unorddd2 (_Decimal64, _Decimal64); +BID_EXTERN_C CMPtype __bid_unordsd2 (_Decimal32, _Decimal32); +BID_EXTERN_C CMPtype __bid_unordtd2 (_Decimal128, _Decimal128); +BID_EXTERN_C _Decimal64 __bid_muldd3 (_Decimal64, _Decimal64); +BID_EXTERN_C _Decimal32 __bid_mulsd3 (_Decimal32, _Decimal32); +BID_EXTERN_C _Decimal128 __bid_multd3 (_Decimal128, _Decimal128); +BID_EXTERN_C _Decimal64 __bid_extendsddd2 (_Decimal32); +BID_EXTERN_C DFtype __bid_extendsddf (_Decimal32); +BID_EXTERN_C DItype __bid_fixsddi (_Decimal32); +BID_EXTERN_C SFtype __bid_truncsdsf (_Decimal32); +BID_EXTERN_C SItype __bid_fixsdsi (_Decimal32); +BID_EXTERN_C _Decimal128 __bid_extendsdtd2 (_Decimal32); +#if BID_HAS_TF_MODE +BID_EXTERN_C TFtype __bid_extendsdtf (_Decimal32); +#endif +BID_EXTERN_C UDItype __bid_fixunssddi (_Decimal32); +BID_EXTERN_C USItype __bid_fixunssdsi (_Decimal32); +#if BID_HAS_XF_MODE +BID_EXTERN_C XFtype __bid_extendsdxf (_Decimal32); +#endif +BID_EXTERN_C _Decimal64 __bid_extendsfdd (SFtype); +BID_EXTERN_C _Decimal32 __bid_extendsfsd (SFtype); +BID_EXTERN_C _Decimal128 __bid_extendsftd (SFtype); +BID_EXTERN_C _Decimal64 __bid_floatsidd (SItype); +BID_EXTERN_C _Decimal32 __bid_floatsisd (SItype); +BID_EXTERN_C _Decimal128 __bid_floatsitd (SItype); +BID_EXTERN_C _Decimal64 __bid_trunctddd2 (_Decimal128); +BID_EXTERN_C DFtype __bid_trunctddf (_Decimal128); +BID_EXTERN_C DItype __bid_fixtddi (_Decimal128); +BID_EXTERN_C _Decimal32 __bid_trunctdsd2 (_Decimal128); +BID_EXTERN_C SFtype __bid_trunctdsf (_Decimal128); +BID_EXTERN_C SItype __bid_fixtdsi (_Decimal128); +#if BID_HAS_TF_MODE +BID_EXTERN_C TFtype __bid_trunctdtf (_Decimal128); +#endif +BID_EXTERN_C UDItype __bid_fixunstddi (_Decimal128); +BID_EXTERN_C USItype __bid_fixunstdsi (_Decimal128); +#if BID_HAS_XF_MODE +BID_EXTERN_C XFtype __bid_trunctdxf (_Decimal128); +#endif +#if BID_HAS_TF_MODE +BID_EXTERN_C _Decimal64 __bid_trunctfdd (TFtype); +BID_EXTERN_C _Decimal32 __bid_trunctfsd (TFtype); +BID_EXTERN_C _Decimal128 __bid_extendtftd (TFtype); +#endif +BID_EXTERN_C _Decimal64 __bid_floatunsdidd (UDItype); +BID_EXTERN_C _Decimal32 __bid_floatunsdisd (UDItype); +BID_EXTERN_C _Decimal128 __bid_floatunsditd (UDItype); +BID_EXTERN_C _Decimal64 __bid_floatunssidd (USItype); +BID_EXTERN_C _Decimal32 __bid_floatunssisd (USItype); +BID_EXTERN_C _Decimal128 __bid_floatunssitd (USItype); +#if BID_HAS_XF_MODE +BID_EXTERN_C _Decimal64 __bid_truncxfdd (XFtype); +BID_EXTERN_C _Decimal32 __bid_truncxfsd (XFtype); +BID_EXTERN_C _Decimal128 __bid_extendxftd (XFtype); +#endif +BID_EXTERN_C int isinfd32 (_Decimal32); +BID_EXTERN_C int isinfd64 (_Decimal64); +BID_EXTERN_C int isinfd128 (_Decimal128); +#endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ + +BID_EXTERN_C void __dfp_set_round (int); +BID_EXTERN_C int __dfp_get_round (void); +BID_EXTERN_C void __dfp_clear_except (void); +BID_EXTERN_C int __dfp_test_except (int); +BID_EXTERN_C void __dfp_raise_except (int); + +#if BID_HAS_GCC_DECIMAL_INTRINSICS +/* Used by gcc intrinsics. We have to define them after BID_UINT128 + is defined. */ +union decimal32 { + _Decimal32 d; + BID_UINT32 i; +}; + +union decimal64 { + _Decimal64 d; + BID_UINT64 i; +}; + +union decimal128 { + _Decimal128 d; + BID_UINT128 i; +}; + +#if BID_HAS_TF_MODE +union float128 { + TFtype f; + BID_UINT128 i; +}; +#endif +#endif /* BID_HAS_GCC_DECIMAL_INTRINSICS */ + +#endif /* _BID_GCC_INTRINSICS_H */ diff --git a/reftest/bid_internal.h b/reftest/bid_internal.h new file mode 100644 index 0000000..674416d --- /dev/null +++ b/reftest/bid_internal.h @@ -0,0 +1,2955 @@ +/****************************************************************************** + Copyright (c) 2007-2024, Intel Corp. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. +******************************************************************************/ + +#ifndef __BIDECIMAL_H +#define __BIDECIMAL_H + +#define _CRT_SECURE_NO_DEPRECATE +#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) +# pragma warning( disable: 4996 ) +#endif + +#include "bid_conf.h" +#include "bid_functions.h" + +#define __BID_INLINE__ static __inline + +#if defined (__INTEL_COMPILER) +#define FENCE __fence +#else +#define FENCE +#endif + +/********************************************************************* + * + * Logical Shift Macros + * + *********************************************************************/ + +#define __shr_128(Q, A, k) \ +{ \ + (Q).w[0] = (A).w[0] >> k; \ + (Q).w[0] |= (A).w[1] << (64-k); \ + (Q).w[1] = (A).w[1] >> k; \ +} + +#define __shr_128_long(Q, A, k) \ +{ \ + if((k)<64) { \ + (Q).w[0] = (A).w[0] >> k; \ + (Q).w[0] |= (A).w[1] << (64-k); \ + (Q).w[1] = (A).w[1] >> k; \ + } \ + else { \ + (Q).w[0] = (A).w[1]>>((k)-64); \ + (Q).w[1] = 0; \ + } \ +} + +#define __shl_128_long(Q, A, k) \ +{ \ + if((k)<64) { \ + (Q).w[1] = (A).w[1] << k; \ + (Q).w[1] |= (A).w[0] >> (64-k); \ + (Q).w[0] = (A).w[0] << k; \ + } \ + else { \ + (Q).w[1] = (A).w[0]<<((k)-64); \ + (Q).w[0] = 0; \ + } \ +} + +#define __low_64(Q) (Q).w[0] +/********************************************************************* + * + * String Macros + * + *********************************************************************/ +#define tolower_macro(x) (((unsigned char)((x)-'A')<=('Z'-'A'))?((x)-'A'+'a'):(x)) +/********************************************************************* + * + * Compare Macros + * + *********************************************************************/ +// greater than +// return 0 if A<=B +// non-zero if A>B +#define __unsigned_compare_gt_128(A, B) \ + ((A.w[1]>B.w[1]) || ((A.w[1]==B.w[1]) && (A.w[0]>B.w[0]))) +// greater-or-equal +#define __unsigned_compare_ge_128(A, B) \ + ((A.w[1]>B.w[1]) || ((A.w[1]==B.w[1]) && (A.w[0]>=B.w[0]))) +#define __test_equal_128(A, B) (((A).w[1]==(B).w[1]) && ((A).w[0]==(B).w[0])) +// tighten exponent range +#define __tight_bin_range_128(bp, P, bin_expon) \ +{ \ +BID_UINT64 M; \ + M = 1; \ + (bp) = (bin_expon); \ + if((bp)<63) { \ + M <<= ((bp)+1); \ + if((P).w[0] >= M) (bp)++; } \ + else if((bp)>64) { \ + M <<= ((bp)+1-64); \ + if(((P).w[1]>M) ||((P).w[1]==M && (P).w[0]))\ + (bp)++; } \ + else if((P).w[1]) (bp)++; \ +} +/********************************************************************* + * + * Add/Subtract Macros + * + *********************************************************************/ +// add 64-bit value to 128-bit +#define __add_128_64(R128, A128, B64) \ +{ \ +BID_UINT64 R64H; \ + R64H = (A128).w[1]; \ + (R128).w[0] = (B64) + (A128).w[0]; \ + if((R128).w[0] < (B64)) \ + R64H ++; \ + (R128).w[1] = R64H; \ +} +// subtract 64-bit value from 128-bit +#define __sub_128_64(R128, A128, B64) \ +{ \ +BID_UINT64 R64H; \ + R64H = (A128).w[1]; \ + if((A128).w[0] < (B64)) \ + R64H --; \ + (R128).w[1] = R64H; \ + (R128).w[0] = (A128).w[0] - (B64); \ +} +// add 128-bit value to 128-bit +// assume no carry-out +#define __add_128_128(R128, A128, B128) \ +{ \ +BID_UINT128 Q128; \ + Q128.w[1] = (A128).w[1]+(B128).w[1]; \ + Q128.w[0] = (B128).w[0] + (A128).w[0]; \ + if(Q128.w[0] < (B128).w[0]) \ + Q128.w[1] ++; \ + (R128).w[1] = Q128.w[1]; \ + (R128).w[0] = Q128.w[0]; \ +} +#define __sub_128_128(R128, A128, B128) \ +{ \ +BID_UINT128 Q128; \ + Q128.w[1] = (A128).w[1]-(B128).w[1]; \ + Q128.w[0] = (A128).w[0] - (B128).w[0]; \ + if((A128).w[0] < (B128).w[0]) \ + Q128.w[1] --; \ + (R128).w[1] = Q128.w[1]; \ + (R128).w[0] = Q128.w[0]; \ +} +#define __add_carry_out(S, CY, X, Y) \ +{ \ +BID_UINT64 X1=X; \ + S = X + Y; \ + CY = (SX1) ? 1 : 0; \ +} +#define __sub_borrow_in_out(S, CY, X, Y, CI) \ +{ \ +BID_UINT64 X1, X0=X; \ + X1 = X - CI; \ + S = X1 - Y; \ + CY = ((S>X1) || (X1>X0)) ? 1 : 0; \ +} +// increment C128 and check for rounding overflow: +// if (C_128) = 10^34 then (C_128) = 10^33 and increment the exponent +#define INCREMENT(C_128, exp) \ +{ \ + C_128.w[0]++; \ + if (C_128.w[0] == 0) C_128.w[1]++; \ + if (C_128.w[1] == 0x0001ed09bead87c0ull && \ + C_128.w[0] == 0x378d8e6400000000ull) { \ + exp++; \ + C_128.w[1] = 0x0000314dc6448d93ull; \ + C_128.w[0] = 0x38c15b0a00000000ull; \ + } \ +} +// decrement C128 and check for rounding underflow, but only at the +// boundary: if C_128 = 10^33 - 1 and exp > 0 then C_128 = 10^34 - 1 +// and decrement the exponent +#define DECREMENT(C_128, exp) \ +{ \ + C_128.w[0]--; \ + if (C_128.w[0] == 0xffffffffffffffffull) C_128.w[1]--; \ + if (C_128.w[1] == 0x0000314dc6448d93ull && \ + C_128.w[0] == 0x38c15b09ffffffffull && exp > 0) { \ + exp--; \ + C_128.w[1] = 0x0001ed09bead87c0ull; \ + C_128.w[0] = 0x378d8e63ffffffffull; \ + } \ +} + + /********************************************************************* + * + * Multiply Macros + * + *********************************************************************/ +#define __mul_64x64_to_64(P64, CX, CY) (P64) = (CX) * (CY) +/*************************************** + * Signed, Full 64x64-bit Multiply + ***************************************/ +#define __imul_64x64_to_128(P, CX, CY) \ +{ \ +BID_UINT64 SX, SY; \ + __mul_64x64_to_128(P, CX, CY); \ + \ + SX = ((BID_SINT64)(CX))>>63; \ + SY = ((BID_SINT64)(CY))>>63; \ + SX &= CY; SY &= CX; \ + \ + (P).w[1] = (P).w[1] - SX - SY; \ +} +/*************************************** + * Signed, Full 64x128-bit Multiply + ***************************************/ +#define __imul_64x128_full(Ph, Ql, A, B) \ +{ \ +BID_UINT128 ALBL, ALBH, QM2, QM; \ + \ + __imul_64x64_to_128(ALBH, (A), (B).w[1]); \ + __imul_64x64_to_128(ALBL, (A), (B).w[0]); \ + \ + (Ql).w[0] = ALBL.w[0]; \ + QM.w[0] = ALBL.w[1]; \ + QM.w[1] = ((BID_SINT64)ALBL.w[1])>>63; \ + __add_128_128(QM2, ALBH, QM); \ + (Ql).w[1] = QM2.w[0]; \ + Ph = QM2.w[1]; \ +} +/***************************************************** + * Unsigned Multiply Macros + *****************************************************/ +// get full 64x64bit product +// +#define __mul_64x64_to_128(P, CX, CY) \ +{ \ +BID_UINT64 CXH, CXL, CYH,CYL,PL,PH,PM,PM2;\ + CXH = (CX) >> 32; \ + CXL = (BID_UINT32)(CX); \ + CYH = (CY) >> 32; \ + CYL = (BID_UINT32)(CY); \ + \ + PM = CXH*CYL; \ + PH = CXH*CYH; \ + PL = CXL*CYL; \ + PM2 = CXL*CYH; \ + PH += (PM>>32); \ + PM = (BID_UINT64)((BID_UINT32)PM)+PM2+(PL>>32); \ + \ + (P).w[1] = PH + (PM>>32); \ + (P).w[0] = (PM<<32)+(BID_UINT32)PL; \ +} +// get full 64x64bit product +// Note: +// This macro is used for CX < 2^61, CY < 2^61 +// +#define __mul_64x64_to_128_fast(P, CX, CY) \ +{ \ +BID_UINT64 CXH, CXL, CYH, CYL, PL, PH, PM; \ + CXH = (CX) >> 32; \ + CXL = (BID_UINT32)(CX); \ + CYH = (CY) >> 32; \ + CYL = (BID_UINT32)(CY); \ + \ + PM = CXH*CYL; \ + PL = CXL*CYL; \ + PH = CXH*CYH; \ + PM += CXL*CYH; \ + PM += (PL>>32); \ + \ + (P).w[1] = PH + (PM>>32); \ + (P).w[0] = (PM<<32)+(BID_UINT32)PL; \ +} +// used for CX< 2^60 +#define __sqr64_fast(P, CX) \ +{ \ +BID_UINT64 CXH, CXL, PL, PH, PM; \ + CXH = (CX) >> 32; \ + CXL = (BID_UINT32)(CX); \ + \ + PM = CXH*CXL; \ + PL = CXL*CXL; \ + PH = CXH*CXH; \ + PM += PM; \ + PM += (PL>>32); \ + \ + (P).w[1] = PH + (PM>>32); \ + (P).w[0] = (PM<<32)+(BID_UINT32)PL; \ +} +// get full 64x64bit product +// Note: +// This implementation is used for CX < 2^61, CY < 2^61 +// +#define __mul_64x64_to_64_high_fast(P, CX, CY) \ +{ \ +BID_UINT64 CXH, CXL, CYH, CYL, PL, PH, PM; \ + CXH = (CX) >> 32; \ + CXL = (BID_UINT32)(CX); \ + CYH = (CY) >> 32; \ + CYL = (BID_UINT32)(CY); \ + \ + PM = CXH*CYL; \ + PL = CXL*CYL; \ + PH = CXH*CYH; \ + PM += CXL*CYH; \ + PM += (PL>>32); \ + \ + (P) = PH + (PM>>32); \ +} +// get full 64x64bit product +// +#define __mul_64x64_to_128_full(P, CX, CY) \ +{ \ +BID_UINT64 CXH, CXL, CYH,CYL,PL,PH,PM,PM2;\ + CXH = (CX) >> 32; \ + CXL = (BID_UINT32)(CX); \ + CYH = (CY) >> 32; \ + CYL = (BID_UINT32)(CY); \ + \ + PM = CXH*CYL; \ + PH = CXH*CYH; \ + PL = CXL*CYL; \ + PM2 = CXL*CYH; \ + PH += (PM>>32); \ + PM = (BID_UINT64)((BID_UINT32)PM)+PM2+(PL>>32); \ + \ + (P).w[1] = PH + (PM>>32); \ + (P).w[0] = (PM<<32)+(BID_UINT32)PL; \ +} +#define __mul_128x128_high(Q, A, B) \ +{ \ +BID_UINT128 ALBL, ALBH, AHBL, AHBH, QM, QM2; \ + \ + __mul_64x64_to_128(ALBH, (A).w[0], (B).w[1]); \ + __mul_64x64_to_128(AHBL, (B).w[0], (A).w[1]); \ + __mul_64x64_to_128(ALBL, (A).w[0], (B).w[0]); \ + __mul_64x64_to_128(AHBH, (A).w[1],(B).w[1]); \ + \ + __add_128_128(QM, ALBH, AHBL); \ + __add_128_64(QM2, QM, ALBL.w[1]); \ + __add_128_64((Q), AHBH, QM2.w[1]); \ +} +#define __mul_128x128_full(Qh, Ql, A, B) \ +{ \ +BID_UINT128 ALBL, ALBH, AHBL, AHBH, QM, QM2; \ + \ + __mul_64x64_to_128(ALBH, (A).w[0], (B).w[1]); \ + __mul_64x64_to_128(AHBL, (B).w[0], (A).w[1]); \ + __mul_64x64_to_128(ALBL, (A).w[0], (B).w[0]); \ + __mul_64x64_to_128(AHBH, (A).w[1],(B).w[1]); \ + \ + __add_128_128(QM, ALBH, AHBL); \ + (Ql).w[0] = ALBL.w[0]; \ + __add_128_64(QM2, QM, ALBL.w[1]); \ + __add_128_64((Qh), AHBH, QM2.w[1]); \ + (Ql).w[1] = QM2.w[0]; \ +} +#define __mul_128x128_low(Ql, A, B) \ +{ \ +BID_UINT128 ALBL; \ +BID_UINT64 QM64; \ + \ + __mul_64x64_to_128(ALBL, (A).w[0], (B).w[0]); \ + QM64 = (B).w[0]*(A).w[1] + (A).w[0]*(B).w[1]; \ + \ + (Ql).w[0] = ALBL.w[0]; \ + (Ql).w[1] = QM64 + ALBL.w[1]; \ +} +#define __mul_64x128_low(Ql, A, B) \ +{ \ + BID_UINT128 ALBL, ALBH, QM2; \ + __mul_64x64_to_128(ALBH, (A), (B).w[1]); \ + __mul_64x64_to_128(ALBL, (A), (B).w[0]); \ + (Ql).w[0] = ALBL.w[0]; \ + __add_128_64(QM2, ALBH, ALBL.w[1]); \ + (Ql).w[1] = QM2.w[0]; \ +} +#define __mul_64x128_full(Ph, Ql, A, B) \ +{ \ +BID_UINT128 ALBL, ALBH, QM2; \ + \ + __mul_64x64_to_128(ALBH, (A), (B).w[1]); \ + __mul_64x64_to_128(ALBL, (A), (B).w[0]); \ + \ + (Ql).w[0] = ALBL.w[0]; \ + __add_128_64(QM2, ALBH, ALBL.w[1]); \ + (Ql).w[1] = QM2.w[0]; \ + Ph = QM2.w[1]; \ +} +#define __mul_64x128_to_192(Q, A, B) \ +{ \ +BID_UINT128 ALBL, ALBH, QM2; \ + \ + __mul_64x64_to_128(ALBH, (A), (B).w[1]); \ + __mul_64x64_to_128(ALBL, (A), (B).w[0]); \ + \ + (Q).w[0] = ALBL.w[0]; \ + __add_128_64(QM2, ALBH, ALBL.w[1]); \ + (Q).w[1] = QM2.w[0]; \ + (Q).w[2] = QM2.w[1]; \ +} +#define __mul_64x128_to192(Q, A, B) \ +{ \ +BID_UINT128 ALBL, ALBH, QM2; \ + \ + __mul_64x64_to_128(ALBH, (A), (B).w[1]); \ + __mul_64x64_to_128(ALBL, (A), (B).w[0]); \ + \ + (Q).w[0] = ALBL.w[0]; \ + __add_128_64(QM2, ALBH, ALBL.w[1]); \ + (Q).w[1] = QM2.w[0]; \ + (Q).w[2] = QM2.w[1]; \ +} +#define __mul_128x128_to_256(P256, A, B) \ +{ \ +BID_UINT128 Qll, Qlh; \ +BID_UINT64 Phl, Phh, CY1, CY2; \ + \ + __mul_64x128_full(Phl, Qll, A.w[0], B); \ + __mul_64x128_full(Phh, Qlh, A.w[1], B); \ + (P256).w[0] = Qll.w[0]; \ + __add_carry_out((P256).w[1],CY1, Qlh.w[0], Qll.w[1]); \ + __add_carry_in_out((P256).w[2],CY2, Qlh.w[1], Phl, CY1); \ + (P256).w[3] = Phh + CY2; \ +} +// +// For better performance, will check A.w[1] against 0, +// but not B.w[1] +// Use this macro accordingly +#define __mul_128x128_to_256_check_A(P256, A, B) \ +{ \ +BID_UINT128 Qll, Qlh; \ +BID_UINT64 Phl, Phh, CY1, CY2; \ + \ + __mul_64x128_full(Phl, Qll, A.w[0], B); \ + (P256).w[0] = Qll.w[0]; \ + if(A.w[1]) { \ + __mul_64x128_full(Phh, Qlh, A.w[1], B); \ + __add_carry_out((P256).w[1],CY1, Qlh.w[0], Qll.w[1]); \ + __add_carry_in_out((P256).w[2],CY2, Qlh.w[1], Phl, CY1); \ + (P256).w[3] = Phh + CY2; } \ + else { \ + (P256).w[1] = Qll.w[1]; \ + (P256).w[2] = Phl; \ + (P256).w[3] = 0; } \ +} +#define __mul_64x192_to_256(lP, lA, lB) \ +{ \ +BID_UINT128 lP0,lP1,lP2; \ +BID_UINT64 lC; \ + __mul_64x64_to_128(lP0, lA, (lB).w[0]); \ + __mul_64x64_to_128(lP1, lA, (lB).w[1]); \ + __mul_64x64_to_128(lP2, lA, (lB).w[2]); \ + (lP).w[0] = lP0.w[0]; \ + __add_carry_out((lP).w[1],lC,lP1.w[0],lP0.w[1]); \ + __add_carry_in_out((lP).w[2],lC,lP2.w[0],lP1.w[1],lC); \ + (lP).w[3] = lP2.w[1] + lC; \ +} +#define __mul_64x256_to_320(P, A, B) \ +{ \ +BID_UINT128 lP0,lP1,lP2,lP3; \ +BID_UINT64 lC; \ + __mul_64x64_to_128(lP0, A, (B).w[0]); \ + __mul_64x64_to_128(lP1, A, (B).w[1]); \ + __mul_64x64_to_128(lP2, A, (B).w[2]); \ + __mul_64x64_to_128(lP3, A, (B).w[3]); \ + (P).w[0] = lP0.w[0]; \ + __add_carry_out((P).w[1],lC,lP1.w[0],lP0.w[1]); \ + __add_carry_in_out((P).w[2],lC,lP2.w[0],lP1.w[1],lC); \ + __add_carry_in_out((P).w[3],lC,lP3.w[0],lP2.w[1],lC); \ + (P).w[4] = lP3.w[1] + lC; \ +} +#define __mul_192x192_to_384(P, A, B) \ +{ \ +BID_UINT256 P0,P1,P2; \ +BID_UINT64 CY; \ + __mul_64x192_to_256(P0, (A).w[0], B); \ + __mul_64x192_to_256(P1, (A).w[1], B); \ + __mul_64x192_to_256(P2, (A).w[2], B); \ + (P).w[0] = P0.w[0]; \ + __add_carry_out((P).w[1],CY,P1.w[0],P0.w[1]); \ + __add_carry_in_out((P).w[2],CY,P1.w[1],P0.w[2],CY); \ + __add_carry_in_out((P).w[3],CY,P1.w[2],P0.w[3],CY); \ + (P).w[4] = P1.w[3] + CY; \ + __add_carry_out((P).w[2],CY,P2.w[0],(P).w[2]); \ + __add_carry_in_out((P).w[3],CY,P2.w[1],(P).w[3],CY); \ + __add_carry_in_out((P).w[4],CY,P2.w[2],(P).w[4],CY); \ + (P).w[5] = P2.w[3] + CY; \ +} +#define __mul_64x320_to_384(P, A, B) \ +{ \ +BID_UINT128 lP0,lP1,lP2,lP3,lP4; \ +BID_UINT64 lC; \ + __mul_64x64_to_128(lP0, A, (B).w[0]); \ + __mul_64x64_to_128(lP1, A, (B).w[1]); \ + __mul_64x64_to_128(lP2, A, (B).w[2]); \ + __mul_64x64_to_128(lP3, A, (B).w[3]); \ + __mul_64x64_to_128(lP4, A, (B).w[4]); \ + (P).w[0] = lP0.w[0]; \ + __add_carry_out((P).w[1],lC,lP1.w[0],lP0.w[1]); \ + __add_carry_in_out((P).w[2],lC,lP2.w[0],lP1.w[1],lC); \ + __add_carry_in_out((P).w[3],lC,lP3.w[0],lP2.w[1],lC); \ + __add_carry_in_out((P).w[4],lC,lP4.w[0],lP3.w[1],lC); \ + (P).w[5] = lP4.w[1] + lC; \ +} +// A*A +// Full 128x128-bit product +#define __sqr128_to_256(P256, A) \ +{ \ +BID_UINT128 Qll, Qlh, Qhh; \ +BID_UINT64 TMP_C1, TMP_C2; \ + \ + __mul_64x64_to_128(Qhh, A.w[1], A.w[1]); \ + __mul_64x64_to_128(Qlh, A.w[0], A.w[1]); \ + Qhh.w[1] += (Qlh.w[1]>>63); \ + Qlh.w[1] = (Qlh.w[1]+Qlh.w[1])|(Qlh.w[0]>>63); \ + Qlh.w[0] += Qlh.w[0]; \ + __mul_64x64_to_128(Qll, A.w[0], A.w[0]); \ + \ + __add_carry_out((P256).w[1],TMP_C1, Qlh.w[0], Qll.w[1]); \ + (P256).w[0] = Qll.w[0]; \ + __add_carry_in_out((P256).w[2],TMP_C2, Qlh.w[1], Qhh.w[0], TMP_C1); \ + (P256).w[3] = Qhh.w[1]+TMP_C2; \ +} +#define __mul_128x128_to_256_low_high(PQh, PQl, A, B) \ +{ \ +BID_UINT128 Qll, Qlh; \ +BID_UINT64 Phl, Phh, C1, C2; \ + \ + __mul_64x128_full(Phl, Qll, A.w[0], B); \ + __mul_64x128_full(Phh, Qlh, A.w[1], B); \ + (PQl).w[0] = Qll.w[0]; \ + __add_carry_out((PQl).w[1],C1, Qlh.w[0], Qll.w[1]); \ + __add_carry_in_out((PQh).w[0],C2, Qlh.w[1], Phl, C1); \ + (PQh).w[1] = Phh + C2; \ +} +#define __mul_256x256_to_512(P, A, B) \ +{ \ +BID_UINT512 P0,P1,P2,P3; \ +BID_UINT64 CY; \ + __mul_64x256_to_320(P0, (A).w[0], B); \ + __mul_64x256_to_320(P1, (A).w[1], B); \ + __mul_64x256_to_320(P2, (A).w[2], B); \ + __mul_64x256_to_320(P3, (A).w[3], B); \ + (P).w[0] = P0.w[0]; \ + __add_carry_out((P).w[1],CY,P1.w[0],P0.w[1]); \ + __add_carry_in_out((P).w[2],CY,P1.w[1],P0.w[2],CY); \ + __add_carry_in_out((P).w[3],CY,P1.w[2],P0.w[3],CY); \ + __add_carry_in_out((P).w[4],CY,P1.w[3],P0.w[4],CY); \ + (P).w[5] = P1.w[4] + CY; \ + __add_carry_out((P).w[2],CY,P2.w[0],(P).w[2]); \ + __add_carry_in_out((P).w[3],CY,P2.w[1],(P).w[3],CY); \ + __add_carry_in_out((P).w[4],CY,P2.w[2],(P).w[4],CY); \ + __add_carry_in_out((P).w[5],CY,P2.w[3],(P).w[5],CY); \ + (P).w[6] = P2.w[4] + CY; \ + __add_carry_out((P).w[3],CY,P3.w[0],(P).w[3]); \ + __add_carry_in_out((P).w[4],CY,P3.w[1],(P).w[4],CY); \ + __add_carry_in_out((P).w[5],CY,P3.w[2],(P).w[5],CY); \ + __add_carry_in_out((P).w[6],CY,P3.w[3],(P).w[6],CY); \ + (P).w[7] = P3.w[4] + CY; \ +} +#define __mul_192x256_to_448(P, A, B) \ +{ \ +BID_UINT512 P0,P1,P2; \ +BID_UINT64 CY; \ + __mul_64x256_to_320(P0, (A).w[0], B); \ + __mul_64x256_to_320(P1, (A).w[1], B); \ + __mul_64x256_to_320(P2, (A).w[2], B); \ + (P).w[0] = P0.w[0]; \ + __add_carry_out((P).w[1],CY,P1.w[0],P0.w[1]); \ + __add_carry_in_out((P).w[2],CY,P1.w[1],P0.w[2],CY); \ + __add_carry_in_out((P).w[3],CY,P1.w[2],P0.w[3],CY); \ + __add_carry_in_out((P).w[4],CY,P1.w[3],P0.w[4],CY); \ + (P).w[5] = P1.w[4] + CY; \ + __add_carry_out((P).w[2],CY,P2.w[0],(P).w[2]); \ + __add_carry_in_out((P).w[3],CY,P2.w[1],(P).w[3],CY); \ + __add_carry_in_out((P).w[4],CY,P2.w[2],(P).w[4],CY); \ + __add_carry_in_out((P).w[5],CY,P2.w[3],(P).w[5],CY); \ + (P).w[6] = P2.w[4] + CY; \ +} +#define __mul_320x320_to_640(P, A, B) \ +{ \ +BID_UINT512 P0,P1,P2,P3; \ +BID_UINT64 CY; \ + __mul_256x256_to_512((P), (A), B); \ + __mul_64x256_to_320(P1, (A).w[4], B); \ + __mul_64x256_to_320(P2, (B).w[4], A); \ + __mul_64x64_to_128(P3, (A).w[4], (B).w[4]); \ + __add_carry_out((P0).w[0],CY,P1.w[0],P2.w[0]); \ + __add_carry_in_out((P0).w[1],CY,P1.w[1],P2.w[1],CY); \ + __add_carry_in_out((P0).w[2],CY,P1.w[2],P2.w[2],CY); \ + __add_carry_in_out((P0).w[3],CY,P1.w[3],P2.w[3],CY); \ + __add_carry_in_out((P0).w[4],CY,P1.w[4],P2.w[4],CY); \ + P3.w[1] += CY; \ + __add_carry_out((P).w[4],CY,(P).w[4],P0.w[0]); \ + __add_carry_in_out((P).w[5],CY,(P).w[5],P0.w[1],CY); \ + __add_carry_in_out((P).w[6],CY,(P).w[6],P0.w[2],CY); \ + __add_carry_in_out((P).w[7],CY,(P).w[7],P0.w[3],CY); \ + __add_carry_in_out((P).w[8],CY,P3.w[0],P0.w[4],CY); \ + (P).w[9] = P3.w[1] + CY; \ +} +#define __mul_384x384_to_768(P, A, B) \ +{ \ +BID_UINT512 P0,P1,P2,P3; \ +BID_UINT64 CY; \ + __mul_320x320_to_640((P), (A), B); \ + __mul_64x320_to_384(P1, (A).w[5], B); \ + __mul_64x320_to_384(P2, (B).w[5], A); \ + __mul_64x64_to_128(P3, (A).w[5], (B).w[5]); \ + __add_carry_out((P0).w[0],CY,P1.w[0],P2.w[0]); \ + __add_carry_in_out((P0).w[1],CY,P1.w[1],P2.w[1],CY); \ + __add_carry_in_out((P0).w[2],CY,P1.w[2],P2.w[2],CY); \ + __add_carry_in_out((P0).w[3],CY,P1.w[3],P2.w[3],CY); \ + __add_carry_in_out((P0).w[4],CY,P1.w[4],P2.w[4],CY); \ + __add_carry_in_out((P0).w[5],CY,P1.w[5],P2.w[5],CY); \ + P3.w[1] += CY; \ + __add_carry_out((P).w[5],CY,(P).w[5],P0.w[0]); \ + __add_carry_in_out((P).w[6],CY,(P).w[6],P0.w[1],CY); \ + __add_carry_in_out((P).w[7],CY,(P).w[7],P0.w[2],CY); \ + __add_carry_in_out((P).w[8],CY,(P).w[8],P0.w[3],CY); \ + __add_carry_in_out((P).w[9],CY,(P).w[9],P0.w[4],CY); \ + __add_carry_in_out((P).w[10],CY,P3.w[0],P0.w[5],CY); \ + (P).w[11] = P3.w[1] + CY; \ +} +#define __mul_64x128_short(Ql, A, B) \ +{ \ +BID_UINT64 ALBH_L; \ + \ + __mul_64x64_to_64(ALBH_L, (A),(B).w[1]); \ + __mul_64x64_to_128((Ql), (A), (B).w[0]); \ + \ + (Ql).w[1] += ALBH_L; \ +} +#define __scale128_10(D,_TMP) \ +{ \ +BID_UINT128 _TMP2,_TMP8; \ + _TMP2.w[1] = (_TMP.w[1]<<1)|(_TMP.w[0]>>63); \ + _TMP2.w[0] = _TMP.w[0]<<1; \ + _TMP8.w[1] = (_TMP.w[1]<<3)|(_TMP.w[0]>>61); \ + _TMP8.w[0] = _TMP.w[0]<<3; \ + __add_128_128(D, _TMP2, _TMP8); \ +} +// 64x64-bit product +#define __mul_64x64_to_128MACH(P128, CX64, CY64) \ +{ \ + BID_UINT64 CXH,CXL,CYH,CYL,PL,PH,PM,PM2; \ + CXH = (CX64) >> 32; \ + CXL = (BID_UINT32)(CX64); \ + CYH = (CY64) >> 32; \ + CYL = (BID_UINT32)(CY64); \ + PM = CXH*CYL; \ + PH = CXH*CYH; \ + PL = CXL*CYL; \ + PM2 = CXL*CYH; \ + PH += (PM>>32); \ + PM = (BID_UINT64)((BID_UINT32)PM)+PM2+(PL>>32); \ + (P128).w[1] = PH + (PM>>32); \ + (P128).w[0] = (PM<<32)+(BID_UINT32)PL; \ +} +// 64x64-bit product +#define __mul_64x64_to_128HIGH(P64, CX64, CY64) \ +{ \ + BID_UINT64 CXH,CXL,CYH,CYL,PL,PH,PM,PM2; \ + CXH = (CX64) >> 32; \ + CXL = (BID_UINT32)(CX64); \ + CYH = (CY64) >> 32; \ + CYL = (BID_UINT32)(CY64); \ + PM = CXH*CYL; \ + PH = CXH*CYH; \ + PL = CXL*CYL; \ + PM2 = CXL*CYH; \ + PH += (PM>>32); \ + PM = (BID_UINT64)((BID_UINT32)PM)+PM2+(PL>>32); \ + P64 = PH + (PM>>32); \ +} +#define __mul_128x64_to_128(Q128, A64, B128) \ +{ \ + BID_UINT64 ALBH_L; \ + ALBH_L = (A64) * (B128).w[1]; \ + __mul_64x64_to_128MACH((Q128), (A64), (B128).w[0]); \ + (Q128).w[1] += ALBH_L; \ +} +// might simplify by calculating just QM2.w[0] +#define __mul_64x128_to_128(Ql, A, B) \ +{ \ + BID_UINT128 ALBL, ALBH, QM2; \ + __mul_64x64_to_128(ALBH, (A), (B).w[1]); \ + __mul_64x64_to_128(ALBL, (A), (B).w[0]); \ + (Ql).w[0] = ALBL.w[0]; \ + __add_128_64(QM2, ALBH, ALBL.w[1]); \ + (Ql).w[1] = QM2.w[0]; \ +} +/********************************************************************* + * + * BID Pack/Unpack Macros + * + *********************************************************************/ +///////////////////////////////////////// +// BID64 definitions +//////////////////////////////////////// +#define DECIMAL_MAX_EXPON_64 767 +#define DECIMAL_EXPONENT_BIAS 398 +#define MAX_FORMAT_DIGITS 16 +///////////////////////////////////////// +// BID128 definitions +//////////////////////////////////////// +#define DECIMAL_MAX_EXPON_128 12287 +#define DECIMAL_EXPONENT_BIAS_128 6176 +#define MAX_FORMAT_DIGITS_128 34 +///////////////////////////////////////// +// BID32 definitions +//////////////////////////////////////// +#define DECIMAL_MAX_EXPON_32 191 +#define DECIMAL_EXPONENT_BIAS_32 101 +#define MAX_FORMAT_DIGITS_32 7 +//////////////////////////////////////// +// Constant Definitions +/////////////////////////////////////// +#define SPECIAL_ENCODING_MASK64 0x6000000000000000ull +#define INFINITY_MASK64 0x7800000000000000ull +#define SINFINITY_MASK64 0xf800000000000000ull +#define SSNAN_MASK64 0xfc00000000000000ull +#define NAN_MASK64 0x7c00000000000000ull +#define SNAN_MASK64 0x7e00000000000000ull +#define QUIET_MASK64 0xfdffffffffffffffull +#define LARGE_COEFF_MASK64 0x0007ffffffffffffull +#define LARGE_COEFF_HIGH_BIT64 0x0020000000000000ull +#define SMALL_COEFF_MASK64 0x001fffffffffffffull +#define EXPONENT_MASK64 0x3ff +#define EXPONENT_SHIFT_LARGE64 51 +#define EXPONENT_SHIFT_SMALL64 53 +#define LARGEST_BID64 0x77fb86f26fc0ffffull +#define SMALLEST_BID64 0xf7fb86f26fc0ffffull +#define SMALL_COEFF_MASK128 0x0001ffffffffffffull +#define LARGE_COEFF_MASK128 0x00007fffffffffffull +#define EXPONENT_MASK128 0x3fff +#define LARGEST_BID128_HIGH 0x5fffed09bead87c0ull +#define LARGEST_BID128_LOW 0x378d8e63ffffffffull +#define SPECIAL_ENCODING_MASK32 0x60000000ul +#define SINFINITY_MASK32 0xf8000000ul +#define INFINITY_MASK32 0x78000000ul +#define LARGE_COEFF_MASK32 0x007ffffful +#define LARGE_COEFF_HIGH_BIT32 0x00800000ul +#define SMALL_COEFF_MASK32 0x001ffffful +#define EXPONENT_MASK32 0xff +#define LARGEST_BID32 0x77f8967f +#define NAN_MASK32 0x7c000000 +#define SNAN_MASK32 0x7e000000 +#define SSNAN_MASK32 0xfc000000 +#define QUIET_MASK32 0xfdffffff +#define MASK_BINARY_EXPONENT 0x7ff0000000000000ull +#define BINARY_EXPONENT_BIAS 0x3ff +#define UPPER_EXPON_LIMIT 51 +// data needed for BID pack/unpack macros +BID_EXTERN_C BID_UINT64 bid_round_const_table[][19]; +BID_EXTERN_C BID_UINT128 bid_reciprocals10_128[]; +BID_EXTERN_C int bid_recip_scale[]; +BID_EXTERN_C BID_UINT128 bid_power10_table_128[]; +BID_EXTERN_C int bid_estimate_decimal_digits[]; +BID_EXTERN_C int bid_estimate_bin_expon[]; +BID_EXTERN_C BID_UINT64 bid_power10_index_binexp[]; +BID_EXTERN_C int bid_short_recip_scale[]; +BID_EXTERN_C int bid_bid_bid_recip_scale32[]; +BID_EXTERN_C BID_UINT64 bid_reciprocals10_64[]; +BID_EXTERN_C BID_UINT64 bid_bid_reciprocals10_32[]; +BID_EXTERN_C BID_UINT128 bid_power10_index_binexp_128[]; +BID_EXTERN_C BID_UINT128 bid_round_const_table_128[][36]; + + +////////////////////////////////////////////// +// Status Flag Handling +///////////////////////////////////////////// +#define __set_status_flags(fpsc, status) *(fpsc) |= status +#define is_inexact(fpsc) ((*(fpsc))&BID_INEXACT_EXCEPTION) + +__BID_INLINE__ BID_UINT64 +unpack_BID64 (BID_UINT64 * psign_x, int *pexponent_x, + BID_UINT64 * pcoefficient_x, BID_UINT64 x) { + BID_UINT64 tmp, coeff; + + *psign_x = x & 0x8000000000000000ull; + + if ((x & SPECIAL_ENCODING_MASK64) == SPECIAL_ENCODING_MASK64) { + // special encodings + // coefficient + coeff = (x & LARGE_COEFF_MASK64) | LARGE_COEFF_HIGH_BIT64; + + if ((x & INFINITY_MASK64) == INFINITY_MASK64) { + *pexponent_x = 0; + *pcoefficient_x = x & 0xfe03ffffffffffffull; + if ((x & 0x0003ffffffffffffull) >= 1000000000000000ull) + *pcoefficient_x = x & 0xfe00000000000000ull; + if ((x & NAN_MASK64) == INFINITY_MASK64) + *pcoefficient_x = x & SINFINITY_MASK64; + return 0; // NaN or Infinity + } + // check for non-canonical values + if (coeff >= 10000000000000000ull) + coeff = 0; + *pcoefficient_x = coeff; + // get exponent + tmp = x >> EXPONENT_SHIFT_LARGE64; + *pexponent_x = (int) (tmp & EXPONENT_MASK64); + return coeff; + } + // exponent + tmp = x >> EXPONENT_SHIFT_SMALL64; + *pexponent_x = (int) (tmp & EXPONENT_MASK64); + // coefficient + *pcoefficient_x = (x & SMALL_COEFF_MASK64); + + return *pcoefficient_x; +} + +// +// BID64 pack macro (general form) +// +__BID_INLINE__ BID_UINT64 +get_BID64 (BID_UINT64 sgn, int expon, BID_UINT64 coeff, int rmode, + unsigned *fpsc) { + BID_UINT128 Stemp, Q_low; + BID_UINT64 QH, r, mask, _C64, remainder_h, CY, carry; + int extra_digits, amount, amount2; + unsigned status; + + if (coeff > 9999999999999999ull) { + expon++; + coeff = 1000000000000000ull; + } + // check for possible underflow/overflow + if (((unsigned) expon) >= 3 * 256) { + if (expon < 0) { + // underflow + if (expon + MAX_FORMAT_DIGITS < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, + BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == BID_ROUNDING_DOWN && sgn) + return 0x8000000000000001ull; + if (rmode == BID_ROUNDING_UP && !sgn) + return 1ull; +#endif +#endif + // result is 0 + return sgn; + } +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#endif +#endif + // get digits to be shifted out + extra_digits = -expon; + coeff += bid_round_const_table[rmode][extra_digits]; + + // get coeff*(2^M[extra_digits])/10^extra_digits + __mul_64x128_full (QH, Q_low, coeff, + bid_reciprocals10_128[extra_digits]); + + // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 + amount = bid_recip_scale[extra_digits]; + + _C64 = QH >> amount; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == 0) //BID_ROUNDING_TO_NEAREST +#endif + if (_C64 & 1) { + // check whether fractional part of initial_P/10^extra_digits is exactly .5 + + // get remainder + amount2 = 64 - amount; + remainder_h = 0; + remainder_h--; + remainder_h >>= amount2; + remainder_h = remainder_h & QH; + + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) { + _C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + + if (is_inexact (fpsc)) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION); + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + remainder_h = QH << (64 - amount); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (remainder_h == 0x8000000000000000ull + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp.w[0], CY, Q_low.w[0], + bid_reciprocals10_128[extra_digits].w[0]); + __add_carry_in_out (Stemp.w[1], carry, Q_low.w[1], + bid_reciprocals10_128[extra_digits].w[1], CY); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64) 1) << amount)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | status); + } + +#endif + + return sgn | _C64; + } + if(!coeff) { if(expon > DECIMAL_MAX_EXPON_64) expon = DECIMAL_MAX_EXPON_64; } + while (coeff < 1000000000000000ull && expon >= 3 * 256) { + expon--; + coeff = (coeff << 3) + (coeff << 1); + } + if (expon > DECIMAL_MAX_EXPON_64) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif + // overflow + r = sgn | INFINITY_MASK64; + switch (rmode) { + case BID_ROUNDING_DOWN: + if (!sgn) + r = LARGEST_BID64; + break; + case BID_ROUNDING_TO_ZERO: + r = sgn | LARGEST_BID64; + break; + case BID_ROUNDING_UP: + // round up + if (sgn) + r = SMALLEST_BID64; + default: + break; + } + return r; + } + } + + mask = 1; + mask <<= EXPONENT_SHIFT_SMALL64; + + // check whether coefficient fits in 10*5+3 bits + if (coeff < mask) { + r = expon; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (coeff | sgn); + return r; + } + // special format + + // eliminate the case coeff==10^16 after rounding + if (coeff == 10000000000000000ull) { + r = expon + 1; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (1000000000000000ull | sgn); + return r; + } + + r = expon; + r <<= EXPONENT_SHIFT_LARGE64; + r |= (sgn | SPECIAL_ENCODING_MASK64); + // add coeff, without leading bits + mask = (mask >> 2) - 1; + coeff &= mask; + r |= coeff; + + return r; +} + + + + +// +// No overflow/underflow checking +// +__BID_INLINE__ BID_UINT64 +fast_get_BID64 (BID_UINT64 sgn, int expon, BID_UINT64 coeff) { + BID_UINT64 r, mask; + + mask = 1; + mask <<= EXPONENT_SHIFT_SMALL64; + + // check whether coefficient fits in 10*5+3 bits + if (coeff < mask) { + r = expon; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (coeff | sgn); + return r; + } + // special format + + // eliminate the case coeff==10^16 after rounding + if (coeff == 10000000000000000ull) { + r = expon + 1; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (1000000000000000ull | sgn); + return r; + } + + r = expon; + r <<= EXPONENT_SHIFT_LARGE64; + r |= (sgn | SPECIAL_ENCODING_MASK64); + // add coeff, without leading bits + mask = (mask >> 2) - 1; + coeff &= mask; + r |= coeff; + + return r; +} + + +// +// no underflow checking +// +__BID_INLINE__ BID_UINT64 +fast_get_BID64_check_OF (BID_UINT64 sgn, int expon, BID_UINT64 coeff, int rmode, + unsigned *fpsc) { + BID_UINT64 r, mask; + + if (((unsigned) expon) >= 3 * 256 - 1) { + if ((expon == 3 * 256 - 1) && coeff == 10000000000000000ull) { + expon = 3 * 256; + coeff = 1000000000000000ull; + } + + if (((unsigned) expon) >= 3 * 256) { + while (coeff < 1000000000000000ull && expon >= 3 * 256) { + expon--; + coeff = (coeff << 3) + (coeff << 1); + } + if (expon > DECIMAL_MAX_EXPON_64) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, + BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif + // overflow + r = sgn | INFINITY_MASK64; + switch (rmode) { + case BID_ROUNDING_DOWN: + if (!sgn) + r = LARGEST_BID64; + break; + case BID_ROUNDING_TO_ZERO: + r = sgn | LARGEST_BID64; + break; + case BID_ROUNDING_UP: + // round up + if (sgn) + r = SMALLEST_BID64; + default: + break; + } + return r; + } + } + } + + mask = 1; + mask <<= EXPONENT_SHIFT_SMALL64; + + // check whether coefficient fits in 10*5+3 bits + if (coeff < mask) { + r = expon; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (coeff | sgn); + return r; + } + // special format + + // eliminate the case coeff==10^16 after rounding + if (coeff == 10000000000000000ull) { + r = expon + 1; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (1000000000000000ull | sgn); + return r; + } + + r = expon; + r <<= EXPONENT_SHIFT_LARGE64; + r |= (sgn | SPECIAL_ENCODING_MASK64); + // add coeff, without leading bits + mask = (mask >> 2) - 1; + coeff &= mask; + r |= coeff; + + return r; +} + + +// +// No overflow/underflow checking +// or checking for coefficients equal to 10^16 (after rounding) +// +__BID_INLINE__ BID_UINT64 +very_fast_get_BID64 (BID_UINT64 sgn, int expon, BID_UINT64 coeff) { + BID_UINT64 r, mask; + + mask = 1; + mask <<= EXPONENT_SHIFT_SMALL64; + + // check whether coefficient fits in 10*5+3 bits + if (coeff < mask) { + r = expon; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (coeff | sgn); + return r; + } + // special format + r = expon; + r <<= EXPONENT_SHIFT_LARGE64; + r |= (sgn | SPECIAL_ENCODING_MASK64); + // add coeff, without leading bits + mask = (mask >> 2) - 1; + coeff &= mask; + r |= coeff; + + return r; +} + +// +// No overflow/underflow checking or checking for coefficients above 2^53 +// +__BID_INLINE__ BID_UINT64 +very_fast_get_BID64_small_mantissa (BID_UINT64 sgn, int expon, BID_UINT64 coeff) { + // no UF/OF + BID_UINT64 r; + + r = expon; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (coeff | sgn); + return r; +} + + +// +// This pack macro is used when underflow is known to occur +// +__BID_INLINE__ BID_UINT64 +get_BID64_UF (BID_UINT64 sgn, int expon, BID_UINT64 coeff, BID_UINT64 R, int rmode, + unsigned *fpsc) { + BID_UINT128 C128, Q_low, Stemp; + BID_UINT64 _C64, remainder_h, QH, carry, CY; + int extra_digits, amount, amount2; + unsigned status; + + // underflow + if (expon + MAX_FORMAT_DIGITS < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == BID_ROUNDING_DOWN && sgn) + return 0x8000000000000001ull; + if (rmode == BID_ROUNDING_UP && !sgn) + return 1ull; +#endif +#endif + // result is 0 + return sgn; + } + // 10*coeff + coeff = (coeff << 3) + (coeff << 1); +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#endif +#endif + if (R) + coeff |= 1; + // get digits to be shifted out + extra_digits = 1 - expon; + C128.w[0] = coeff + bid_round_const_table[rmode][extra_digits]; + + // get coeff*(2^M[extra_digits])/10^extra_digits + __mul_64x128_full (QH, Q_low, C128.w[0], + bid_reciprocals10_128[extra_digits]); + + // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 + amount = bid_recip_scale[extra_digits]; + + _C64 = QH >> amount; + //__shr_128(C128, Q_high, amount); + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == 0) //BID_ROUNDING_TO_NEAREST +#endif + if (_C64 & 1) { + // check whether fractional part of initial_P/10^extra_digits is exactly .5 + + // get remainder + amount2 = 64 - amount; + remainder_h = 0; + remainder_h--; + remainder_h >>= amount2; + remainder_h = remainder_h & QH; + + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) { + _C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + + if (is_inexact (fpsc)) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION); + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + remainder_h = QH << (64 - amount); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (remainder_h == 0x8000000000000000ull + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp.w[0], CY, Q_low.w[0], + bid_reciprocals10_128[extra_digits].w[0]); + __add_carry_in_out (Stemp.w[1], carry, Q_low.w[1], + bid_reciprocals10_128[extra_digits].w[1], CY); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64) 1) << amount)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | status); + } + +#endif + + return sgn | _C64; + +} + + + +// +// This pack macro doesnot check for coefficients above 2^53 +// +__BID_INLINE__ BID_UINT64 +get_BID64_small_mantissa (BID_UINT64 sgn, int expon, BID_UINT64 coeff, + int rmode, unsigned *fpsc) { + BID_UINT128 C128, Q_low, Stemp; + BID_UINT64 r, mask, _C64, remainder_h, QH, carry, CY; + int extra_digits, amount, amount2; + unsigned status; + + // check for possible underflow/overflow + if (((unsigned) expon) >= 3 * 256) { + if (expon < 0) { + // underflow + if (expon + MAX_FORMAT_DIGITS < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, + BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == BID_ROUNDING_DOWN && sgn) + return 0x8000000000000001ull; + if (rmode == BID_ROUNDING_UP && !sgn) + return 1ull; +#endif +#endif + // result is 0 + return sgn; + } +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#endif +#endif + // get digits to be shifted out + extra_digits = -expon; + C128.w[0] = coeff + bid_round_const_table[rmode][extra_digits]; + + // get coeff*(2^M[extra_digits])/10^extra_digits + __mul_64x128_full (QH, Q_low, C128.w[0], + bid_reciprocals10_128[extra_digits]); + + // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 + amount = bid_recip_scale[extra_digits]; + + _C64 = QH >> amount; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == 0) //BID_ROUNDING_TO_NEAREST +#endif + if (_C64 & 1) { + // check whether fractional part of initial_P/10^extra_digits is exactly .5 + + // get remainder + amount2 = 64 - amount; + remainder_h = 0; + remainder_h--; + remainder_h >>= amount2; + remainder_h = remainder_h & QH; + + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) { + _C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + + if (is_inexact (fpsc)) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION); + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + remainder_h = QH << (64 - amount); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (remainder_h == 0x8000000000000000ull + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h + && (Q_low.w[1] < bid_reciprocals10_128[extra_digits].w[1] + || (Q_low.w[1] == bid_reciprocals10_128[extra_digits].w[1] + && Q_low.w[0] < + bid_reciprocals10_128[extra_digits].w[0]))) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp.w[0], CY, Q_low.w[0], + bid_reciprocals10_128[extra_digits].w[0]); + __add_carry_in_out (Stemp.w[1], carry, Q_low.w[1], + bid_reciprocals10_128[extra_digits].w[1], CY); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64) 1) << amount)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | status); + } + +#endif + + return sgn | _C64; + } + + while (coeff < 1000000000000000ull && expon >= 3 * 256) { + expon--; + coeff = (coeff << 3) + (coeff << 1); + } + if (expon > DECIMAL_MAX_EXPON_64) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif + // overflow + r = sgn | INFINITY_MASK64; + switch (rmode) { + case BID_ROUNDING_DOWN: + if (!sgn) + r = LARGEST_BID64; + break; + case BID_ROUNDING_TO_ZERO: + r = sgn | LARGEST_BID64; + break; + case BID_ROUNDING_UP: + // round up + if (sgn) + r = SMALLEST_BID64; + } + return r; + } else { + mask = 1; + mask <<= EXPONENT_SHIFT_SMALL64; + if (coeff >= mask) { + r = expon; + r <<= EXPONENT_SHIFT_LARGE64; + r |= (sgn | SPECIAL_ENCODING_MASK64); + // add coeff, without leading bits + mask = (mask >> 2) - 1; + coeff &= mask; + r |= coeff; + return r; + } + } + } + + r = expon; + r <<= EXPONENT_SHIFT_SMALL64; + r |= (coeff | sgn); + + return r; +} + + +/***************************************************************************** +* +* BID128 pack/unpack macros +* +*****************************************************************************/ + +// +// Macro for handling BID128 underflow +// sticky bit given as additional argument +// +__BID_INLINE__ BID_UINT128 * +bid_handle_UF_128_rem (BID_UINT128 * pres, BID_UINT64 sgn, int expon, BID_UINT128 CQ, + BID_UINT64 R, unsigned *prounding_mode, unsigned *fpsc) { + BID_UINT128 T128, TP128, Qh, Ql, Qh1, Stemp, Tmp, Tmp1, CQ2, CQ8; + BID_UINT64 carry, CY; + int ed2, amount; + unsigned rmode, status; + + // UF occurs + if (expon + MAX_FORMAT_DIGITS_128 < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif + pres->w[1] = sgn; + pres->w[0] = 0; +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if ((sgn && *prounding_mode == BID_ROUNDING_DOWN) + || (!sgn && *prounding_mode == BID_ROUNDING_UP)) + pres->w[0] = 1ull; +#endif +#endif + return pres; + } + // CQ *= 10 + CQ2.w[1] = (CQ.w[1] << 1) | (CQ.w[0] >> 63); + CQ2.w[0] = CQ.w[0] << 1; + CQ8.w[1] = (CQ.w[1] << 3) | (CQ.w[0] >> 61); + CQ8.w[0] = CQ.w[0] << 3; + __add_128_128 (CQ, CQ2, CQ8); + + // add remainder + if (R) + CQ.w[0] |= 1; + + ed2 = 1 - expon; + // add rounding constant to CQ +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + rmode = *prounding_mode; + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#else + rmode = 0; +#endif +#else + rmode = 0; +#endif + T128 = bid_round_const_table_128[rmode][ed2]; + __add_carry_out (CQ.w[0], carry, T128.w[0], CQ.w[0]); + CQ.w[1] = CQ.w[1] + T128.w[1] + carry; + + TP128 = bid_reciprocals10_128[ed2]; + __mul_128x128_full (Qh, Ql, CQ, TP128); + amount = bid_recip_scale[ed2]; + + if (amount >= 64) { + CQ.w[0] = Qh.w[1] >> (amount - 64); + CQ.w[1] = 0; + } else { + __shr_128 (CQ, Qh, amount); + } + + expon = 0; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (!(*prounding_mode)) +#endif + if (CQ.w[0] & 1) { + // check whether fractional part of initial_P/10^ed1 is exactly .5 + + // get remainder + __shl_128_long (Qh1, Qh, (128 - amount)); + + if (!Qh1.w[1] && !Qh1.w[0] + && (Ql.w[1] < bid_reciprocals10_128[ed2].w[1] + || (Ql.w[1] == bid_reciprocals10_128[ed2].w[1] + && Ql.w[0] < bid_reciprocals10_128[ed2].w[0]))) { + CQ.w[0]--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + + if (is_inexact (fpsc)) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION); + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + __shl_128_long (Qh1, Qh, (128 - amount)); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (Qh1.w[1] == 0x8000000000000000ull && (!Qh1.w[0]) + && (Ql.w[1] < bid_reciprocals10_128[ed2].w[1] + || (Ql.w[1] == bid_reciprocals10_128[ed2].w[1] + && Ql.w[0] < bid_reciprocals10_128[ed2].w[0]))) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if ((!Qh1.w[1]) && (!Qh1.w[0]) + && (Ql.w[1] < bid_reciprocals10_128[ed2].w[1] + || (Ql.w[1] == bid_reciprocals10_128[ed2].w[1] + && Ql.w[0] < bid_reciprocals10_128[ed2].w[0]))) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp.w[0], CY, Ql.w[0], + bid_reciprocals10_128[ed2].w[0]); + __add_carry_in_out (Stemp.w[1], carry, Ql.w[1], + bid_reciprocals10_128[ed2].w[1], CY); + __shr_128_long (Qh, Qh1, (128 - amount)); + Tmp.w[0] = 1; + Tmp.w[1] = 0; + __shl_128_long (Tmp1, Tmp, amount); + Qh.w[0] += carry; + if (Qh.w[0] < carry) + Qh.w[1]++; + if (__unsigned_compare_ge_128 (Qh, Tmp1)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | status); + } + +#endif + + pres->w[1] = sgn | CQ.w[1]; + pres->w[0] = CQ.w[0]; + + return pres; + +} + + +// +// Macro for handling BID128 underflow +// +__BID_INLINE__ BID_UINT128 * +handle_UF_128 (BID_UINT128 * pres, BID_UINT64 sgn, int expon, BID_UINT128 CQ, + unsigned *prounding_mode, unsigned *fpsc) { + BID_UINT128 T128, TP128, Qh, Ql, Qh1, Stemp, Tmp, Tmp1; + BID_UINT64 carry, CY; + int ed2, amount; + unsigned rmode, status; + + // UF occurs + if (expon + MAX_FORMAT_DIGITS_128 < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif + pres->w[1] = sgn; + pres->w[0] = 0; +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if ((sgn && *prounding_mode == BID_ROUNDING_DOWN) + || (!sgn && *prounding_mode == BID_ROUNDING_UP)) + pres->w[0] = 1ull; +#endif +#endif + return pres; + } + + ed2 = 0 - expon; + // add rounding constant to CQ +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + rmode = *prounding_mode; + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#else + rmode = 0; +#endif +#else + rmode = 0; +#endif + + T128 = bid_round_const_table_128[rmode][ed2]; + __add_carry_out (CQ.w[0], carry, T128.w[0], CQ.w[0]); + CQ.w[1] = CQ.w[1] + T128.w[1] + carry; + + TP128 = bid_reciprocals10_128[ed2]; + __mul_128x128_full (Qh, Ql, CQ, TP128); + amount = bid_recip_scale[ed2]; + + if (amount >= 64) { + CQ.w[0] = Qh.w[1] >> (amount - 64); + CQ.w[1] = 0; + } else { + __shr_128 (CQ, Qh, amount); + } + + expon = 0; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (!(*prounding_mode)) +#endif + if (CQ.w[0] & 1) { + // check whether fractional part of initial_P/10^ed1 is exactly .5 + + // get remainder + __shl_128_long (Qh1, Qh, (128 - amount)); + + if (!Qh1.w[1] && !Qh1.w[0] + && (Ql.w[1] < bid_reciprocals10_128[ed2].w[1] + || (Ql.w[1] == bid_reciprocals10_128[ed2].w[1] + && Ql.w[0] < bid_reciprocals10_128[ed2].w[0]))) { + CQ.w[0]--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + + if (is_inexact (fpsc)) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION); + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + __shl_128_long (Qh1, Qh, (128 - amount)); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (Qh1.w[1] == 0x8000000000000000ull && (!Qh1.w[0]) + && (Ql.w[1] < bid_reciprocals10_128[ed2].w[1] + || (Ql.w[1] == bid_reciprocals10_128[ed2].w[1] + && Ql.w[0] < bid_reciprocals10_128[ed2].w[0]))) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if ((!Qh1.w[1]) && (!Qh1.w[0]) + && (Ql.w[1] < bid_reciprocals10_128[ed2].w[1] + || (Ql.w[1] == bid_reciprocals10_128[ed2].w[1] + && Ql.w[0] < bid_reciprocals10_128[ed2].w[0]))) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp.w[0], CY, Ql.w[0], + bid_reciprocals10_128[ed2].w[0]); + __add_carry_in_out (Stemp.w[1], carry, Ql.w[1], + bid_reciprocals10_128[ed2].w[1], CY); + __shr_128_long (Qh, Qh1, (128 - amount)); + Tmp.w[0] = 1; + Tmp.w[1] = 0; + __shl_128_long (Tmp1, Tmp, amount); + Qh.w[0] += carry; + if (Qh.w[0] < carry) + Qh.w[1]++; + if (__unsigned_compare_ge_128 (Qh, Tmp1)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | status); + } + +#endif + + pres->w[1] = sgn | CQ.w[1]; + pres->w[0] = CQ.w[0]; + + return pres; + +} + + + +// +// BID128 unpack, input passed by value (used in transcendental functions only) +// +__BID_INLINE__ BID_UINT64 +unpack_BID128_value_BLE (BID_UINT64 * psign_x, int *pexponent_x, + BID_UINT128 * pcoefficient_x, BID_UINT128 x) { + BID_UINT128 coeff, T33, T34; + BID_UINT64 ex; + + *psign_x = (x.w[BID_HIGH_128W]) & 0x8000000000000000ull; + + // special encodings + if ((x.w[BID_HIGH_128W] & INFINITY_MASK64) >= SPECIAL_ENCODING_MASK64) { + if ((x.w[BID_HIGH_128W] & INFINITY_MASK64) < INFINITY_MASK64) { + // non-canonical input + pcoefficient_x->w[BID_LOW_128W] = 0; + pcoefficient_x->w[BID_HIGH_128W] = 0; + ex = (x.w[BID_HIGH_128W]) >> 47; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + return 0; + } + // 10^33 + T33 = bid_power10_table_128[33]; + + pcoefficient_x->w[BID_LOW_128W] = x.w[BID_LOW_128W]; + pcoefficient_x->w[BID_HIGH_128W] = (x.w[BID_HIGH_128W]) & 0x00003fffffffffffull; + if ((pcoefficient_x->w[BID_HIGH_128W]>T33.w[1]) || ((pcoefficient_x->w[BID_HIGH_128W]==T33.w[1]) && (pcoefficient_x->w[BID_LOW_128W]>=T33.w[0]))) // non-canonical + { + pcoefficient_x->w[BID_HIGH_128W] = (x.w[BID_HIGH_128W]) & 0xfe00000000000000ull; + pcoefficient_x->w[BID_LOW_128W] = 0; + } else + pcoefficient_x->w[BID_HIGH_128W] = (x.w[BID_HIGH_128W]) & 0xfe003fffffffffffull; + if ((x.w[BID_HIGH_128W] & NAN_MASK64) == INFINITY_MASK64) { + pcoefficient_x->w[BID_LOW_128W] = 0; + pcoefficient_x->w[BID_HIGH_128W] = x.w[BID_HIGH_128W] & SINFINITY_MASK64; + } + *pexponent_x = 0; + return 0; // NaN or Infinity + } + + coeff.w[BID_LOW_128W] = x.w[BID_LOW_128W]; + coeff.w[BID_HIGH_128W] = (x.w[BID_HIGH_128W]) & SMALL_COEFF_MASK128; + + // 10^34 + T34 = bid_power10_table_128[34]; + // check for non-canonical values + if ((coeff.w[BID_HIGH_128W]>T34.w[1]) || ((coeff.w[BID_HIGH_128W]==T34.w[1]) && (coeff.w[BID_LOW_128W]>=T34.w[0]))) { + coeff.w[BID_LOW_128W] = coeff.w[BID_HIGH_128W] = 0;} + + pcoefficient_x->w[BID_LOW_128W] = coeff.w[BID_LOW_128W]; + pcoefficient_x->w[BID_HIGH_128W] = coeff.w[BID_HIGH_128W]; + + ex = (x.w[BID_HIGH_128W]) >> 49; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + + return coeff.w[BID_LOW_128W] | coeff.w[BID_HIGH_128W]; +} + + + +// +// BID128 unpack, input passed by value +// +__BID_INLINE__ BID_UINT64 +unpack_BID128_value (BID_UINT64 * psign_x, int *pexponent_x, + BID_UINT128 * pcoefficient_x, BID_UINT128 x) { + BID_UINT128 coeff, T33, T34; + BID_UINT64 ex; + + *psign_x = (x.w[1]) & 0x8000000000000000ull; + + // special encodings + if ((x.w[1] & INFINITY_MASK64) >= SPECIAL_ENCODING_MASK64) { + if ((x.w[1] & INFINITY_MASK64) < INFINITY_MASK64) { + // non-canonical input + pcoefficient_x->w[0] = 0; + pcoefficient_x->w[1] = 0; + ex = (x.w[1]) >> 47; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + return 0; + } + // 10^33 + T33 = bid_power10_table_128[33]; + /*coeff.w[0] = x.w[0]; + coeff.w[1] = (x.w[1]) & LARGE_COEFF_MASK128; + pcoefficient_x->w[0] = x.w[0]; + pcoefficient_x->w[1] = x.w[1]; + if (__unsigned_compare_ge_128 (coeff, T33)) // non-canonical + pcoefficient_x->w[1] &= (~LARGE_COEFF_MASK128); */ + + pcoefficient_x->w[0] = x.w[0]; + pcoefficient_x->w[1] = (x.w[1]) & 0x00003fffffffffffull; + if (__unsigned_compare_ge_128 ((*pcoefficient_x), T33)) // non-canonical + { + pcoefficient_x->w[1] = (x.w[1]) & 0xfe00000000000000ull; + pcoefficient_x->w[0] = 0; + } else + pcoefficient_x->w[1] = (x.w[1]) & 0xfe003fffffffffffull; + if ((x.w[1] & NAN_MASK64) == INFINITY_MASK64) { + pcoefficient_x->w[0] = 0; + pcoefficient_x->w[1] = x.w[1] & SINFINITY_MASK64; + } + *pexponent_x = 0; + return 0; // NaN or Infinity + } + + coeff.w[0] = x.w[0]; + coeff.w[1] = (x.w[1]) & SMALL_COEFF_MASK128; + + // 10^34 + T34 = bid_power10_table_128[34]; + // check for non-canonical values + if (__unsigned_compare_ge_128 (coeff, T34)) + coeff.w[0] = coeff.w[1] = 0; + + pcoefficient_x->w[0] = coeff.w[0]; + pcoefficient_x->w[1] = coeff.w[1]; + + ex = (x.w[1]) >> 49; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + + return coeff.w[0] | coeff.w[1]; +} + +// +// BID128 unpack, input passed by value +// +__BID_INLINE__ void +quick_unpack_BID128_em (int *pexponent_x, + BID_UINT128 * pcoefficient_x, BID_UINT128 x) { + BID_UINT64 ex; + + pcoefficient_x->w[0] = x.w[0]; + pcoefficient_x->w[1] = (x.w[1]) & SMALL_COEFF_MASK128; + + ex = (x.w[1]) >> 49; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + +} + + +// +// BID128 unpack, input pased by reference +// +__BID_INLINE__ BID_UINT64 +unpack_BID128 (BID_UINT64 * psign_x, int *pexponent_x, + BID_UINT128 * pcoefficient_x, BID_UINT128 * px) { + BID_UINT128 coeff, T33, T34; + BID_UINT64 ex; + + *psign_x = (px->w[1]) & 0x8000000000000000ull; + + // special encodings + if ((px->w[1] & INFINITY_MASK64) >= SPECIAL_ENCODING_MASK64) { + if ((px->w[1] & INFINITY_MASK64) < INFINITY_MASK64) { + // non-canonical input + pcoefficient_x->w[0] = 0; + pcoefficient_x->w[1] = 0; + ex = (px->w[1]) >> 47; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + return 0; + } + // 10^33 + T33 = bid_power10_table_128[33]; + coeff.w[0] = px->w[0]; + coeff.w[1] = (px->w[1]) & LARGE_COEFF_MASK128; + pcoefficient_x->w[0] = px->w[0]; + pcoefficient_x->w[1] = px->w[1]; + if (__unsigned_compare_ge_128 (coeff, T33)) { // non-canonical + pcoefficient_x->w[1] &= (~LARGE_COEFF_MASK128); + pcoefficient_x->w[0] = 0; + } + *pexponent_x = 0; + return 0; // NaN or Infinity + } + + coeff.w[0] = px->w[0]; + coeff.w[1] = (px->w[1]) & SMALL_COEFF_MASK128; + + // 10^34 + T34 = bid_power10_table_128[34]; + // check for non-canonical values + if (__unsigned_compare_ge_128 (coeff, T34)) + coeff.w[0] = coeff.w[1] = 0; + + pcoefficient_x->w[0] = coeff.w[0]; + pcoefficient_x->w[1] = coeff.w[1]; + + ex = (px->w[1]) >> 49; + *pexponent_x = ((int) ex) & EXPONENT_MASK128; + + return coeff.w[0] | coeff.w[1]; +} + +// +// Pack macro checks for overflow, but not underflow +// +__BID_INLINE__ BID_UINT128 * +bid_get_BID128_very_fast_OF (BID_UINT128 * pres, BID_UINT64 sgn, int expon, + BID_UINT128 coeff, unsigned *prounding_mode, + unsigned *fpsc) { + BID_UINT128 T; + BID_UINT64 tmp, tmp2; + + if ((unsigned) expon > DECIMAL_MAX_EXPON_128) { + + if (expon - MAX_FORMAT_DIGITS_128 <= DECIMAL_MAX_EXPON_128) { + T = bid_power10_table_128[MAX_FORMAT_DIGITS_128 - 1]; + while (__unsigned_compare_gt_128 (T, coeff) + && expon > DECIMAL_MAX_EXPON_128) { + coeff.w[1] = + (coeff.w[1] << 3) + (coeff.w[1] << 1) + (coeff.w[0] >> 61) + + (coeff.w[0] >> 63); + tmp2 = coeff.w[0] << 3; + coeff.w[0] = (coeff.w[0] << 1) + tmp2; + if (coeff.w[0] < tmp2) + coeff.w[1]++; + + expon--; + } + } + if ((unsigned) expon > DECIMAL_MAX_EXPON_128) { + // OF +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (*prounding_mode == BID_ROUNDING_TO_ZERO + || (sgn && *prounding_mode == BID_ROUNDING_UP) || (!sgn + && + *prounding_mode + == + BID_ROUNDING_DOWN)) + { + pres->w[1] = sgn | LARGEST_BID128_HIGH; + pres->w[0] = LARGEST_BID128_LOW; + } else +#endif +#endif + { + pres->w[1] = sgn | INFINITY_MASK64; + pres->w[0] = 0; + } + return pres; + } + } + + pres->w[0] = coeff.w[0]; + tmp = expon; + tmp <<= 49; + pres->w[1] = sgn | tmp | coeff.w[1]; + + return pres; +} + + +// +// No overflow/underflow checks +// No checking for coefficient == 10^34 (rounding artifact) +// +__BID_INLINE__ BID_UINT128 * +bid_get_BID128_very_fast (BID_UINT128 * pres, BID_UINT64 sgn, int expon, + BID_UINT128 coeff) { + BID_UINT64 tmp; + + pres->w[0] = coeff.w[0]; + tmp = expon; + tmp <<= 49; + pres->w[1] = sgn | tmp | coeff.w[1]; + + return pres; +} + +// same as above, but for either endian mode +__BID_INLINE__ BID_UINT128 * +bid_get_BID128_very_fast_BLE (BID_UINT128 * pres, BID_UINT64 sgn, int expon, + BID_UINT128 coeff) { + BID_UINT64 tmp; + + pres->w[BID_LOW_128W] = coeff.w[BID_LOW_128W]; + tmp = expon; + tmp <<= 49; + pres->w[BID_HIGH_128W] = sgn | tmp | coeff.w[BID_HIGH_128W]; + + return pres; +} + +// +// No overflow/underflow checks +// +__BID_INLINE__ BID_UINT128 * +bid_get_BID128_fast (BID_UINT128 * pres, BID_UINT64 sgn, int expon, BID_UINT128 coeff) { + BID_UINT64 tmp; + + // coeff==10^34? + if (coeff.w[1] == 0x0001ed09bead87c0ull + && coeff.w[0] == 0x378d8e6400000000ull) { + expon++; + // set coefficient to 10^33 + coeff.w[1] = 0x0000314dc6448d93ull; + coeff.w[0] = 0x38c15b0a00000000ull; + } + + pres->w[0] = coeff.w[0]; + tmp = expon; + tmp <<= 49; + pres->w[1] = sgn | tmp | coeff.w[1]; + + return pres; +} + +// +// General BID128 pack macro +// +__BID_INLINE__ BID_UINT128 * +bid_get_BID128 (BID_UINT128 * pres, BID_UINT64 sgn, int expon, BID_UINT128 coeff, + unsigned *prounding_mode, unsigned *fpsc) { + BID_UINT128 T; + BID_UINT64 tmp, tmp2; + + // coeff==10^34? + if (coeff.w[1] == 0x0001ed09bead87c0ull + && coeff.w[0] == 0x378d8e6400000000ull) { + expon++; + // set coefficient to 10^33 + coeff.w[1] = 0x0000314dc6448d93ull; + coeff.w[0] = 0x38c15b0a00000000ull; + } + // check OF, UF + if (expon < 0 || expon > DECIMAL_MAX_EXPON_128) { + // check UF + if (expon < 0) { + return handle_UF_128 (pres, sgn, expon, coeff, prounding_mode, + fpsc); + } + + if (expon - MAX_FORMAT_DIGITS_128 <= DECIMAL_MAX_EXPON_128) { + T = bid_power10_table_128[MAX_FORMAT_DIGITS_128 - 1]; + while (__unsigned_compare_gt_128 (T, coeff) + && expon > DECIMAL_MAX_EXPON_128) { + coeff.w[1] = + (coeff.w[1] << 3) + (coeff.w[1] << 1) + (coeff.w[0] >> 61) + + (coeff.w[0] >> 63); + tmp2 = coeff.w[0] << 3; + coeff.w[0] = (coeff.w[0] << 1) + tmp2; + if (coeff.w[0] < tmp2) + coeff.w[1]++; + + expon--; + } + } + if (expon > DECIMAL_MAX_EXPON_128) { + if (!(coeff.w[1] | coeff.w[0])) { + pres->w[1] = sgn | (((BID_UINT64) DECIMAL_MAX_EXPON_128) << 49); + pres->w[0] = 0; + return pres; + } + // OF +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (*prounding_mode == BID_ROUNDING_TO_ZERO + || (sgn && *prounding_mode == BID_ROUNDING_UP) || (!sgn + && + *prounding_mode + == + BID_ROUNDING_DOWN)) + { + pres->w[1] = sgn | LARGEST_BID128_HIGH; + pres->w[0] = LARGEST_BID128_LOW; + } else +#endif +#endif + { + pres->w[1] = sgn | INFINITY_MASK64; + pres->w[0] = 0; + } + return pres; + } + } + + pres->w[0] = coeff.w[0]; + tmp = expon; + tmp <<= 49; + pres->w[1] = sgn | tmp | coeff.w[1]; + + return pres; +} + + +// +// Macro used for conversions from string +// (no additional arguments given for rounding mode, status flags) +// +__BID_INLINE__ BID_UINT128 * +bid_get_BID128_string (BID_UINT128 * pres, BID_UINT64 sgn, int expon, BID_UINT128 coeff) { + BID_UINT128 D2, D8; + BID_UINT64 tmp; + unsigned rmode = 0, status; + + // coeff==10^34? + if (coeff.w[1] == 0x0001ed09bead87c0ull + && coeff.w[0] == 0x378d8e6400000000ull) { + expon++; + // set coefficient to 10^33 + coeff.w[1] = 0x0000314dc6448d93ull; + coeff.w[0] = 0x38c15b0a00000000ull; + } + // check OF, UF + if ((unsigned) expon > DECIMAL_MAX_EXPON_128) { + // check UF + if (expon < 0) + return handle_UF_128 (pres, sgn, expon, coeff, &rmode, &status); + + // OF + + if (expon < DECIMAL_MAX_EXPON_128 + 34) { + while (expon > DECIMAL_MAX_EXPON_128 && + (coeff.w[1] < bid_power10_table_128[33].w[1] || + (coeff.w[1] == bid_power10_table_128[33].w[1] + && coeff.w[0] < bid_power10_table_128[33].w[0]))) { + D2.w[1] = (coeff.w[1] << 1) | (coeff.w[0] >> 63); + D2.w[0] = coeff.w[0] << 1; + D8.w[1] = (coeff.w[1] << 3) | (coeff.w[0] >> 61); + D8.w[0] = coeff.w[0] << 3; + + __add_128_128 (coeff, D2, D8); + expon--; + } + } else if (!(coeff.w[0] | coeff.w[1])) + expon = DECIMAL_MAX_EXPON_128; + + if (expon > DECIMAL_MAX_EXPON_128) { + pres->w[1] = sgn | INFINITY_MASK64; + pres->w[0] = 0; + switch (rmode) { + case BID_ROUNDING_DOWN: + if (!sgn) { + pres->w[1] = LARGEST_BID128_HIGH; + pres->w[0] = LARGEST_BID128_LOW; + } + break; + case BID_ROUNDING_TO_ZERO: + pres->w[1] = sgn | LARGEST_BID128_HIGH; + pres->w[0] = LARGEST_BID128_LOW; + break; + case BID_ROUNDING_UP: + // round up + if (sgn) { + pres->w[1] = sgn | LARGEST_BID128_HIGH; + pres->w[0] = LARGEST_BID128_LOW; + } + break; + } + + return pres; + } + } + + pres->w[0] = coeff.w[0]; + tmp = expon; + tmp <<= 49; + pres->w[1] = sgn | tmp | coeff.w[1]; + + return pres; +} + + + +/***************************************************************************** +* +* BID32 pack/unpack macros +* +*****************************************************************************/ + + +__BID_INLINE__ BID_UINT32 +unpack_BID32 (BID_UINT32 * psign_x, int *pexponent_x, + BID_UINT32 * pcoefficient_x, BID_UINT32 x) { + BID_UINT32 tmp; + + *psign_x = x & 0x80000000; + + if ((x & SPECIAL_ENCODING_MASK32) == SPECIAL_ENCODING_MASK32) { + // special encodings + if ((x & INFINITY_MASK32) == INFINITY_MASK32) { + *pcoefficient_x = x & 0xfe0fffff; + if ((x & 0x000fffff) >= 1000000) + *pcoefficient_x = x & 0xfe000000; + if ((x & NAN_MASK32) == INFINITY_MASK32) + *pcoefficient_x = x & 0xf8000000; + *pexponent_x = 0; + return 0; // NaN or Infinity + } + // coefficient + *pcoefficient_x = (x & SMALL_COEFF_MASK32) | LARGE_COEFF_HIGH_BIT32; + // check for non-canonical value + if (*pcoefficient_x >= 10000000) + *pcoefficient_x = 0; + // get exponent + tmp = x >> 21; + *pexponent_x = tmp & EXPONENT_MASK32; + return *pcoefficient_x; + } + // exponent + tmp = x >> 23; + *pexponent_x = tmp & EXPONENT_MASK32; + // coefficient + *pcoefficient_x = (x & LARGE_COEFF_MASK32); + + return *pcoefficient_x; +} + +// +// General pack macro for BID32 +// +__BID_INLINE__ BID_UINT32 +get_BID32 (BID_UINT32 sgn, int expon, BID_UINT64 coeff, int rmode, + unsigned *fpsc) { + BID_UINT128 Q; + BID_UINT64 _C64, remainder_h, carry, Stemp; + BID_UINT32 r, mask; + int extra_digits, amount, amount2; + unsigned status; + + if (coeff > 9999999ull) { + expon++; + coeff = 1000000ull; + } + // check for possible underflow/overflow + if (((unsigned) expon) > DECIMAL_MAX_EXPON_32) { + if (expon < 0) { + // underflow + if (expon + MAX_FORMAT_DIGITS_32 < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, + BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == BID_ROUNDING_DOWN && sgn) + return 0x80000001; + if (rmode == BID_ROUNDING_UP && !sgn) + return 1; +#endif +#endif + // result is 0 + return sgn; + } + // get digits to be shifted out +#ifdef IEEE_ROUND_NEAREST_TIES_AWAY + rmode = 0; +#endif +#ifdef IEEE_ROUND_NEAREST + rmode = 0; +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#endif +#endif + + extra_digits = -expon; + coeff += bid_round_const_table[rmode][extra_digits]; + + // get coeff*(2^M[extra_digits])/10^extra_digits + __mul_64x64_to_128 (Q, coeff, bid_reciprocals10_64[extra_digits]); + + // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 + amount = bid_short_recip_scale[extra_digits]; + + _C64 = Q.w[1] >> amount; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == 0) //BID_ROUNDING_TO_NEAREST +#endif + if (_C64 & 1) { + // check whether fractional part of initial_P/10^extra_digits is exactly .5 + + // get remainder + amount2 = 64 - amount; + remainder_h = 0; + remainder_h--; + remainder_h >>= amount2; + remainder_h = remainder_h & Q.w[1]; + + if (!remainder_h && (Q.w[0] < bid_reciprocals10_64[extra_digits])) { + _C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + + if (is_inexact (fpsc)) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION); + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + remainder_h = Q.w[1] << (64 - amount); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (remainder_h == 0x8000000000000000ull + && (Q.w[0] < bid_reciprocals10_64[extra_digits])) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h && (Q.w[0] < bid_reciprocals10_64[extra_digits])) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp, carry, Q.w[0], + bid_reciprocals10_64[extra_digits]); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64) 1) << amount)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION | status); + } + +#endif + + return sgn | (BID_UINT32) _C64; + } + + if(!coeff) { if(expon > DECIMAL_MAX_EXPON_32) expon = DECIMAL_MAX_EXPON_32; } + while (coeff < 1000000 && expon > DECIMAL_MAX_EXPON_32) { + coeff = (coeff << 3) + (coeff << 1); + expon--; + } + if (((unsigned) expon) > DECIMAL_MAX_EXPON_32) { + __set_status_flags (fpsc, BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); + // overflow + r = sgn | INFINITY_MASK32; + switch (rmode) { + case BID_ROUNDING_DOWN: + if (!sgn) + r = LARGEST_BID32; + break; + case BID_ROUNDING_TO_ZERO: + r = sgn | LARGEST_BID32; + break; + case BID_ROUNDING_UP: + // round up + if (sgn) + r = sgn | LARGEST_BID32; + } + return r; + } + } + + mask = 1 << 23; + + // check whether coefficient fits in DECIMAL_COEFF_FIT bits + if (coeff < mask) { + r = expon; + r <<= 23; + r |= ((BID_UINT32) coeff | sgn); + return r; + } + // special format + + r = expon; + r <<= 21; + r |= (sgn | SPECIAL_ENCODING_MASK32); + // add coeff, without leading bits + mask = (1 << 21) - 1; + r |= (((BID_UINT32) coeff) & mask); + + return r; +} + + + + + +// +// General pack macro for BID32 +// +__BID_INLINE__ BID_UINT32 +get_BID32_UF (BID_UINT32 sgn, int expon, BID_UINT64 coeff, BID_UINT32 R, int rmode, + unsigned *fpsc) { + BID_UINT128 Q; + BID_UINT64 _C64, remainder_h, carry, Stemp; + BID_UINT32 r, mask; + int extra_digits, amount, amount2; + unsigned status; + + if (coeff > 9999999ull) { + expon++; + coeff = 1000000ull; + } + // check for possible underflow/overflow + if (((unsigned) expon) > DECIMAL_MAX_EXPON_32) { + if (expon < 0) { + // underflow + if (expon + MAX_FORMAT_DIGITS_32 < 0) { +#ifdef BID_SET_STATUS_FLAGS + __set_status_flags (fpsc, + BID_UNDERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == BID_ROUNDING_DOWN && sgn) + return 0x80000001; + if (rmode == BID_ROUNDING_UP && !sgn) + return 1; +#endif +#endif + // result is 0 + return sgn; + } + // get digits to be shifted out +#ifdef IEEE_ROUND_NEAREST_TIES_AWAY + rmode = 0; +#endif +#ifdef IEEE_ROUND_NEAREST + rmode = 0; +#endif +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (sgn && (unsigned) (rmode - 1) < 2) + rmode = 3 - rmode; +#endif +#endif + + // 10*coeff + coeff = (coeff << 3) + (coeff << 1); + if (R) + coeff |= 1; + + extra_digits = 1-expon; + coeff += bid_round_const_table[rmode][extra_digits]; + + // get coeff*(2^M[extra_digits])/10^extra_digits + __mul_64x64_to_128 (Q, coeff, bid_reciprocals10_64[extra_digits]); + + // now get P/10^extra_digits: shift Q_high right by M[extra_digits]-128 + amount = bid_short_recip_scale[extra_digits]; + + _C64 = Q.w[1] >> amount; + +#ifndef IEEE_ROUND_NEAREST_TIES_AWAY +#ifndef IEEE_ROUND_NEAREST + if (rmode == 0) //BID_ROUNDING_TO_NEAREST +#endif + if (_C64 & 1) { + // check whether fractional part of initial_P/10^extra_digits is exactly .5 + + // get remainder + amount2 = 64 - amount; + remainder_h = 0; + remainder_h--; + remainder_h >>= amount2; + remainder_h = remainder_h & Q.w[1]; + + if (!remainder_h && (Q.w[0] < bid_reciprocals10_64[extra_digits])) { + _C64--; + } + } +#endif + +#ifdef BID_SET_STATUS_FLAGS + if (is_inexact (fpsc)){ + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION);} + else { + status = BID_INEXACT_EXCEPTION; + // get remainder + remainder_h = Q.w[1] << (64 - amount); + + switch (rmode) { + case BID_ROUNDING_TO_NEAREST: + case BID_ROUNDING_TIES_AWAY: + // test whether fractional part is 0 + if (remainder_h == 0x8000000000000000ull + && (Q.w[0] < bid_reciprocals10_64[extra_digits])) + status = BID_EXACT_STATUS; + break; + case BID_ROUNDING_DOWN: + case BID_ROUNDING_TO_ZERO: + if (!remainder_h && (Q.w[0] < bid_reciprocals10_64[extra_digits])) + status = BID_EXACT_STATUS; + break; + default: + // round up + __add_carry_out (Stemp, carry, Q.w[0], + bid_reciprocals10_64[extra_digits]); + if ((remainder_h >> (64 - amount)) + carry >= + (((BID_UINT64) 1) << amount)) + status = BID_EXACT_STATUS; + } + + if (status != BID_EXACT_STATUS) { + __set_status_flags (fpsc, BID_UNDERFLOW_EXCEPTION|status); + } + } +#endif + + return sgn | (BID_UINT32) _C64; + } + + while (coeff < 1000000 && expon > DECIMAL_MAX_EXPON_32) { + coeff = (coeff << 3) + (coeff << 1); + expon--; + } + if (((unsigned) expon) > DECIMAL_MAX_EXPON_32) { + __set_status_flags (fpsc, BID_OVERFLOW_EXCEPTION | BID_INEXACT_EXCEPTION); + // overflow + r = sgn | INFINITY_MASK32; + switch (rmode) { + case BID_ROUNDING_DOWN: + if (!sgn) + r = LARGEST_BID32; + break; + case BID_ROUNDING_TO_ZERO: + r = sgn | LARGEST_BID32; + break; + case BID_ROUNDING_UP: + // round up + if (sgn) + r = sgn | LARGEST_BID32; + } + return r; + } + } + + mask = 1 << 23; + + // check whether coefficient fits in DECIMAL_COEFF_FIT bits + if (coeff < mask) { + r = expon; + r <<= 23; + r |= ((BID_UINT32) coeff | sgn); + return r; + } + // special format + + r = expon; + r <<= 21; + r |= (sgn | SPECIAL_ENCODING_MASK32); + // add coeff, without leading bits + mask = (1 << 21) - 1; + r |= (((BID_UINT32) coeff) & mask); + + return r; +} + + + + + + +// +// no overflow/underflow checks +// +__BID_INLINE__ BID_UINT32 +very_fast_get_BID32 (BID_UINT32 sgn, int expon, BID_UINT32 coeff) { + BID_UINT32 r, mask; + + mask = 1 << 23; + + // check whether coefficient fits in 10*2+3 bits + if (coeff < mask) { + r = expon; + r <<= 23; + r |= (coeff | sgn); + return r; + } + // special format + r = expon; + r <<= 21; + r |= (sgn | SPECIAL_ENCODING_MASK32); + // add coeff, without leading bits + mask = (1 << 21) - 1; + coeff &= mask; + r |= coeff; + + return r; +} + +__BID_INLINE__ BID_UINT32 +fast_get_BID32 (BID_UINT32 sgn, int expon, BID_UINT32 coeff) { + BID_UINT32 r, mask; + + mask = 1 << 23; + + if (coeff > 9999999ul) { + expon++; + coeff = 1000000ul; + } + // check whether coefficient fits in 10*2+3 bits + if (coeff < mask) { + r = expon; + r <<= 23; + r |= (coeff | sgn); + return r; + } + // special format + r = expon; + r <<= 21; + r |= (sgn | SPECIAL_ENCODING_MASK32); + // add coeff, without leading bits + mask = (1 << 21) - 1; + coeff &= mask; + r |= coeff; + + return r; +} + + + +/************************************************************* + * + *************************************************************/ +typedef struct BID_ALIGN (16) + { + BID_UINT64 w[6]; + } BID_UINT384; + typedef struct BID_ALIGN (16) + { + BID_UINT64 w[8]; + } BID_UINT512; + +// #define P 34 +#define MASK_STEERING_BITS 0x6000000000000000ull +#define MASK_BINARY_EXPONENT1 0x7fe0000000000000ull +#define MASK_BINARY_SIG1 0x001fffffffffffffull +#define MASK_BINARY_EXPONENT2 0x1ff8000000000000ull + //used to take G[2:w+3] (sec 3.3) +#define MASK_BINARY_SIG2 0x0007ffffffffffffull + //used to mask out G4:T0 (sec 3.3) +#define MASK_BINARY_OR2 0x0020000000000000ull + //used to prefix 8+G4 to T (sec 3.3) +#define UPPER_EXPON_LIMIT 51 +#define MASK_EXP 0x7ffe000000000000ull +#define MASK_EXP2 0x1fff800000000000ull +#define MASK_SPECIAL 0x7800000000000000ull +#define MASK_NAN 0x7c00000000000000ull +#define MASK_SNAN 0x7e00000000000000ull +#define MASK_ANY_INF 0x7c00000000000000ull +#define MASK_INF 0x7800000000000000ull +#define MASK_SIGN 0x8000000000000000ull +#define MASK_COEFF 0x0001ffffffffffffull +#define BIN_EXP_BIAS (0x1820ull << 49) + +#define EXP_MIN32 0x00000000 +#define EXP_MAX32 0x5f800000 +#define EXP_MIN 0x0000000000000000ull + // EXP_MIN = (-6176 + 6176) << 49 +#define EXP_MAX 0x5ffe000000000000ull + // EXP_MAX = (6111 + 6176) << 49 +#define EXP_MAX_P1 0x6000000000000000ull + // EXP_MAX + 1 = (6111 + 6176 + 1) << 49 +#define EXP_P1 0x0002000000000000ull + // EXP_ P1= 1 << 49 +#define expmin -6176 + // min unbiased exponent +#define expmax 6111 + // max unbiased exponent +#define expmin16 -398 + // min unbiased exponent +#define expmax16 369 + // max unbiased exponent +#define expmin7 -101 + // min unbiased exponent +#define expmax7 90 + // max unbiased exponent + +#define MASK_INF32 0x78000000 +#define MASK_ANY_INF32 0x7c000000 +#define MASK_SIGN32 0x80000000 +#define MASK_NAN32 0x7c000000 +#define MASK_SNAN32 0x7e000000 +#define SIGNMASK32 0x80000000 +#define BID32_SIG_MAX 0x0098967f +#define BID64_SIG_MAX 0x002386F26FC0ffffull +#define SIGNMASK64 0x8000000000000000ull +#define MASK_STEERING_BITS32 0x60000000 +#define MASK_BINARY_EXPONENT1_32 0x7f800000 +#define MASK_BINARY_SIG1_32 0x007fffff +#define MASK_BINARY_EXPONENT2_32 0x1fe00000 + //used to take G[2:w+3] (sec 3.3) +#define MASK_BINARY_SIG2_32 0x001fffff + //used to mask out G4:T0 (sec 3.3) +#define MASK_BINARY_OR2_32 0x00800000 +#define MASK_SPECIAL32 0x78000000 + +// typedef unsigned int BID_FPSC; // floating-point status and control + // bit31: + // bit30: + // bit29: + // bit28: + // bit27: + // bit26: + // bit25: + // bit24: + // bit23: + // bit22: + // bit21: + // bit20: + // bit19: + // bit18: + // bit17: + // bit16: + // bit15: + // bit14: RC:2 + // bit13: RC:1 + // bit12: RC:0 + // bit11: PM + // bit10: UM + // bit9: OM + // bit8: ZM + // bit7: DM + // bit6: IM + // bit5: PE + // bit4: UE + // bit3: OE + // bit2: ZE + // bit1: DE + // bit0: IE + +#define ROUNDING_BID_MODE_MASK 0x00007000 + + typedef struct _DEC_DIGITS { + unsigned int digits; + BID_UINT64 threshold_hi; + BID_UINT64 threshold_lo; + unsigned int digits1; + } DEC_DIGITS; + + BID_EXTERN_C DEC_DIGITS bid_nr_digits[]; + BID_EXTERN_C BID_UINT64 bid_midpoint64[]; + BID_EXTERN_C BID_UINT128 bid_midpoint128[]; + BID_EXTERN_C BID_UINT192 bid_midpoint192[]; + BID_EXTERN_C BID_UINT256 bid_midpoint256[]; + BID_EXTERN_C BID_UINT64 bid_ten2k64[]; + BID_EXTERN_C BID_UINT128 bid_ten2k128[]; + BID_EXTERN_C BID_UINT256 bid_ten2k256[]; + BID_EXTERN_C BID_UINT128 bid_ten2mk128[]; + BID_EXTERN_C BID_UINT64 bid_ten2mk64[]; + BID_EXTERN_C BID_UINT128 bid_ten2mk128trunc[]; + BID_EXTERN_C int bid_shiftright128[]; + BID_EXTERN_C BID_UINT64 bid_maskhigh128[]; + BID_EXTERN_C BID_UINT64 bid_maskhigh128M[]; + BID_EXTERN_C BID_UINT64 bid_maskhigh192M[]; + BID_EXTERN_C BID_UINT64 bid_maskhigh256M[]; + BID_EXTERN_C BID_UINT64 bid_onehalf128[]; + BID_EXTERN_C BID_UINT64 bid_onehalf128M[]; + BID_EXTERN_C BID_UINT64 bid_onehalf192M[]; + BID_EXTERN_C BID_UINT64 bid_onehalf256M[]; + BID_EXTERN_C BID_UINT128 bid_ten2mk128M[]; + BID_EXTERN_C BID_UINT128 bid_ten2mk128truncM[]; + BID_EXTERN_C BID_UINT192 bid_ten2mk192truncM[]; + BID_EXTERN_C BID_UINT256 bid_ten2mk256truncM[]; + BID_EXTERN_C int bid_shiftright128M[]; + BID_EXTERN_C int bid_shiftright192M[]; + BID_EXTERN_C int bid_shiftright256M[]; + BID_EXTERN_C BID_UINT192 bid_ten2mk192M[]; + BID_EXTERN_C BID_UINT256 bid_ten2mk256M[]; + BID_EXTERN_C unsigned char bid_char_table2[]; + BID_EXTERN_C unsigned char bid_char_table3[]; + + BID_EXTERN_C BID_UINT64 bid_ten2m3k64[]; + BID_EXTERN_C unsigned int bid_shift_ten2m3k64[]; + BID_EXTERN_C BID_UINT128 bid_ten2m3k128[]; + BID_EXTERN_C unsigned int bid_shift_ten2m3k128[]; + + + +/*************************************************************************** + *************** TABLES FOR GENERAL ROUNDING FUNCTIONS ********************* + ***************************************************************************/ + + BID_EXTERN_C BID_UINT64 bid_Kx64[]; + BID_EXTERN_C unsigned int bid_Ex64m64[]; + BID_EXTERN_C BID_UINT64 bid_half64[]; + BID_EXTERN_C BID_UINT64 bid_mask64[]; + BID_EXTERN_C BID_UINT64 bid_ten2mxtrunc64[]; + + BID_EXTERN_C BID_UINT128 bid_Kx128[]; + BID_EXTERN_C unsigned int bid_Ex128m128[]; + BID_EXTERN_C BID_UINT64 bid_half128[]; + BID_EXTERN_C BID_UINT64 bid_mask128[]; + BID_EXTERN_C BID_UINT128 bid_ten2mxtrunc128[]; + + BID_EXTERN_C BID_UINT192 bid_Kx192[]; + BID_EXTERN_C unsigned int bid_Ex192m192[]; + BID_EXTERN_C BID_UINT64 bid_half192[]; + BID_EXTERN_C BID_UINT64 bid_mask192[]; + BID_EXTERN_C BID_UINT192 bid_ten2mxtrunc192[]; + + BID_EXTERN_C BID_UINT256 bid_Kx256[]; + BID_EXTERN_C unsigned int bid_Ex256m256[]; + BID_EXTERN_C BID_UINT64 bid_half256[]; + BID_EXTERN_C BID_UINT64 bid_mask256[]; + BID_EXTERN_C BID_UINT256 bid_ten2mxtrunc256[]; + + typedef union BID_ALIGN (16) __bid64_128 { + BID_UINT64 b64; + BID_UINT128 b128; + } BID64_128; + + BID64_128 bid_fma (unsigned int P0, + BID64_128 x1, unsigned int P1, + BID64_128 y1, unsigned int P2, + BID64_128 z1, unsigned int P3, + unsigned int rnd_mode, BID_FPSC * fpsc); + +#define P7 7 +#define P16 16 +#define P34 34 + + union __int_double { + BID_UINT64 i; + double d; + }; + typedef union __int_double int_double; + + + union __int_float { + BID_UINT32 i; + float d; + }; + typedef union __int_float int_float; + +#define SWAP(A,B,T) {\ + T = A; \ + A = B; \ + B = T; \ +} + +// this macro will find coefficient_x to be in [2^A, 2^(A+1) ) +// ie it knows that it is A bits long +#define NUMBITS(A, coefficient_x, tempx){\ + temp_x.d=(float)coefficient_x;\ + A=((tempx.i >>23) & EXPONENT_MASK32) - 0x7f;\ +} + +typedef union { + BID_UINT32 ui32; + float f; +} BID_UI32FLOAT; + +typedef union { + BID_UINT64 ui64; + double d; +} BID_UI64DOUBLE; + + +////////////////////////////////////////////////// +// Macros for raising exceptions / setting flags +///////////////////////////////////////////////// + +#define bid_raise_except(x) __set_status_flags (pfpsf, (x)) +#define get_bid_sw() (*pfpsf) +#define set_bid_sw(x) (*pfpsf) = (x) + +#endif diff --git a/reftest/go.mod b/reftest/go.mod new file mode 100644 index 0000000..ef10e9c --- /dev/null +++ b/reftest/go.mod @@ -0,0 +1,14 @@ +module github.com/anz-bank/decimal/reftest + +go 1.24.4 + +require github.com/stretchr/testify v1.10.0 + +require ( + github.com/anz-bank/decimal v1.15.0 + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) + +replace github.com/anz-bank/decimal => .. diff --git a/reftest/go.sum b/reftest/go.sum new file mode 100644 index 0000000..c0a85a0 --- /dev/null +++ b/reftest/go.sum @@ -0,0 +1,11 @@ +github.com/anz-bank/decimal v1.15.0 h1:wJ9X6XCVpBUqEwapFamKd0eTbCkJPQe9JJSOoShKykU= +github.com/anz-bank/decimal v1.15.0/go.mod h1:lSAX9MYcSaTIxYaII8tXEJbPom/njRKSAX2VMFVh434= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/reftest/reftest.go b/reftest/reftest.go new file mode 100644 index 0000000..10061c6 --- /dev/null +++ b/reftest/reftest.go @@ -0,0 +1,36 @@ +package reftest + +/* +#include +#include "bid_conf.h" +#include "bid_functions.h" +*/ +import "C" +import ( + "bytes" + "unsafe" +) + +type Dec64 uint64 + +func New64(s string) Dec64 { + cs := C.CString(s) + defer C.free(unsafe.Pointer(cs)) + return Dec64(C.__bid64_from_string(cs, C._IDEC_round(0), nil)) +} + +func (x Dec64) Add(y Dec64) Dec64 { + return Dec64(C.__bid64_add(C.BID_UINT64(x), C.BID_UINT64(y), C._IDEC_round(0), nil)) +} + +func (x Dec64) Mul(y Dec64) Dec64 { + return Dec64(C.__bid64_mul(C.BID_UINT64(x), C.BID_UINT64(y), C._IDEC_round(0), nil)) +} + +func (x Dec64) String() string { + var buf [64]C.char + p := &buf[0] + C.__bid64_to_string(p, C.BID_UINT64(x), nil) + data := C.GoBytes(unsafe.Pointer(p), C.int(len(buf))) + return string(data[:bytes.IndexByte(data, 0)]) +} diff --git a/reftest/reftest_test.go b/reftest/reftest_test.go new file mode 100644 index 0000000..c4d3efd --- /dev/null +++ b/reftest/reftest_test.go @@ -0,0 +1,103 @@ +package reftest_test + +import ( + "fmt" + "math/rand" + "testing" + "unsafe" + + "github.com/anz-bank/decimal/d64" + . "github.com/anz-bank/decimal/reftest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestString(t *testing.T) { + assert.Equal(t, "+123E-2", New64("1.23").String()) + assert.Equal(t, "+456E-2", New64("4.56").String()) + assert.Equal(t, "-4560E-2", New64("-45.60").String()) + assert.NotEqual(t, "-4560E-2", New64("-45.6").String()) + assert.Equal(t, "+Inf", New64("inf").String()) + assert.Equal(t, "+NaN", New64("nan").String()) +} + +func TestAdd(t *testing.T) { + assert.Equal(t, "+579E-2", New64("1.23").Add(New64("4.56")).String()) + assert.Equal(t, "+580E-2", New64("1.23").Add(New64("4.57")).String()) + assert.Equal(t, "+580E-2", New64("1.24").Add(New64("4.56")).String()) +} + +func TestMul(t *testing.T) { + assert.Equal(t, "+56088E-4", New64("1.23").Mul(New64("4.56")).String()) + assert.Equal(t, "+55510E-4", New64("1.22").Mul(New64("4.55")).String()) + assert.Equal(t, "+56500E-4", New64("1.25").Mul(New64("4.52")).String()) + assert.Equal(t, "+54900E-4", New64("1.22").Mul(New64("4.50")).String()) + assert.Equal(t, "+5490E-3", New64("1.22").Mul(New64("4.5")).String()) +} + +func TestD64Add(t *testing.T) { + t.Parallel() + + r := rand.New(rand.NewSource(0)) + for i := range 100 { + x1 := randomDec64(r) + y1 := randomDec64(r) + expected := x1.Add(y1) + x2 := fromDec64(x1) + y2 := fromDec64(y1) + actual := x2.Add(y2) + require.Equal(t, expected, toDec64(actual), "i = %d\nexpected: %v (%s) + %v (%s) = %v (%s)\nactual: %v (%s) + %v (%s) = %v (%s %v)", + i, x1, dec64Raw(x1), y1, dec64Raw(y1), expected, dec64Raw(expected), x2, d64Raw(x2), y2, d64Raw(y2), actual, d64Raw(actual), toDec64(actual)) + } +} + +func TestD64AddOneOff(t *testing.T) { + t.Parallel() + + x1 := Dec64(0b0001100010100001110101000000111110000101010100010100011000111001) + y1 := Dec64(0b1101001111100001111011001000010111100010001011101000100101111000) + expected := x1.Add(y1) + x2 := fromDec64(x1) + y2 := fromDec64(y1) + actual := x2.Add(y2) + require.Equal(t, expected, toDec64(actual), "expected: %v (%s) + %v (%s) = %v (%s)\nactual: %v (%s) + %v (%s) = %v (%s %v)", + x1, dec64Raw(x1), y1, dec64Raw(y1), expected, dec64Raw(expected), x2, d64Raw(x2), y2, d64Raw(y2), actual, d64Raw(actual), toDec64(actual)) +} + +func fromDec64(bits Dec64) d64.Decimal { + var d d64.Decimal + *(*Dec64)(unsafe.Pointer(&d)) = bits + return d +} + +func toDec64(x d64.Decimal) Dec64 { + return *(*Dec64)(unsafe.Pointer(&x)) +} + +func dec64Raw(x Dec64) string { + u := *(*uint64)(unsafe.Pointer(&x)) + return fmt.Sprintf("%01b:%013b:%050b", u>>63%(1<<1), u>>50%(1<<13), u%(1<<50)) +} + +func d64Raw(x d64.Decimal) string { + u := *(*uint64)(unsafe.Pointer(&x)) + return fmt.Sprintf("%01b:%013b:%050b", u>>63, u>>50%(1<<13), u%(1<<50)) +} + +func randomDec64(r *rand.Rand) Dec64 { +loop: + for { + u := r.Uint64() + // log.Printf("%016x", u) + switch (u >> 59) & 0b1111 { + case 0b1100, 0b1101, 0b1110: + if 1<<53+u%(1<<51) > 10_000_000_000_000_000 { + continue loop + } + } + return Dec64(u) + } +} + +// expected: -8252036246683216E+311 (1:1011000101111:01010100010010111011101001001010000011111001010000) + +SNaN (0:1111110001111:01000000101011100101010011010010110111110101111111) = +NaN. (0:1111100000000:01000000101011100101010011010010110111110101111111) +// actual: -8.252036246683216e+326 (1:1011000101111:01010100010010111011101001001010000011111001010000) + NaN�4847 (0:1111110001111:01000000101011100101010011010010110111110101111111) = NaN�2223 (0:1111110000000:01000000101011100101010011010010110111110101111111 +SNaN) From c227b2daed3217c4fb2a6b9f8ce1e23cef89a287 Mon Sep 17 00:00:00 2001 From: Marcelo Cantos <13160581+anzdaddy@users.noreply.github.com> Date: Tue, 22 Jul 2025 08:46:42 +1000 Subject: [PATCH 2/6] optimise common path for + --- d64/decParts.go | 67 +++++++++++++++++++++++++++++++++--------------- d64/decimal.go | 15 +++++++++-- d64/math.go | 36 +++++++++++++++----------- d64/math_test.go | 2 ++ 4 files changed, 82 insertions(+), 38 deletions(-) diff --git a/d64/decParts.go b/d64/decParts.go index fd61177..35b1e1c 100644 --- a/d64/decParts.go +++ b/d64/decParts.go @@ -187,27 +187,52 @@ func (dp *decParts) unpackV2(d Decimal) { } // https://en.wikipedia.org/wiki/Decimal64_floating-point_format#Binary_integer_significand_field -var flavMap = [...]flavor{ - /* 0000xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0001xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0010xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0011xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0100xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0101xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0110xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 0111xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 1000xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 1001xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 1010xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 1011xx */ flNormal53, flNormal53, flNormal53, flNormal53, - /* 1100xx */ flNormal51, flNormal51, flNormal51, flNormal51, - /* 1101xx */ flNormal51, flNormal51, flNormal51, flNormal51, - /* 1110xx */ flNormal51, flNormal51, flNormal51, flNormal51, - /* 11110x */ flInf, flInf, - /* 111110 */ flQNaN, - /* 111111 */ flSNaN, -} +var flavMap = func() [128]flavor { + fm := [...]flavor{ + /* 0000xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0001xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0010xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0011xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0100xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0101xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0110xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0111xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1000xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1001xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1010xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1011xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1100xx */ flNormal51, flNormal51, flNormal51, flNormal51, + /* 1101xx */ flNormal51, flNormal51, flNormal51, flNormal51, + /* 1110xx */ flNormal51, flNormal51, flNormal51, flNormal51, + /* 11110x */ flInf, flInf, + /* 111110 */ flQNaN, + /* 111111 */ flSNaN, + /* 0000xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0001xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0010xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0011xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0100xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0101xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0110xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 0111xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1000xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1001xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1010xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1011xx */ flNormal53, flNormal53, flNormal53, flNormal53, + /* 1100xx */ flNormal51, flNormal51, flNormal51, flNormal51, + /* 1101xx */ flNormal51, flNormal51, flNormal51, flNormal51, + /* 1110xx */ flNormal51, flNormal51, flNormal51, flNormal51, + /* 11110x */ flInf, flInf, + /* 111110 */ flQNaN, + /* 111111 */ flSNaN, + } + return fm +}() func (d Decimal) flavor() flavor { - return flavMap[int(d.bits>>(64-7))%len(flavMap)] + return flavMap[int(d.bits>>(64-7))] +} + +func (d Decimal) isFinite() bool { + return d.bits>>(64-5)&0b1111 < 0b1111 } diff --git a/d64/decimal.go b/d64/decimal.go index 50859dd..dcb1235 100644 --- a/d64/decimal.go +++ b/d64/decimal.go @@ -450,7 +450,7 @@ func (d Decimal) Signbit() bool { func (d Decimal) ScaleB(e Decimal) Decimal { var dp, ep decParts - if nan, is := checkNan(d, e, &dp, &ep); is { + if nan, is := checkNan2(d, e, &dp, &ep); is { return nan } @@ -534,7 +534,18 @@ func (d Decimal) Class() string { return "+Normal-Normal"[7*dp.sign : 7*(dp.sign+1)] } -func checkNan(d, e Decimal, dp, ep *decParts) (Decimal, bool) { +func checkFinite2(d, e Decimal, dp, ep *decParts) bool { + if d.isFinite() && e.isFinite() { + dp.fl = d.flavor() + ep.fl = e.flavor() + dp.unpackV2(d) + ep.unpackV2(e) + return true + } + return false +} + +func checkNan2(d, e Decimal, dp, ep *decParts) (Decimal, bool) { dp.fl = d.flavor() ep.fl = e.flavor() switch { diff --git a/d64/math.go b/d64/math.go index 409e592..82059ea 100644 --- a/d64/math.go +++ b/d64/math.go @@ -58,7 +58,7 @@ func (d Decimal) Quo(e Decimal) Decimal { // +1 if d > e func (d Decimal) Cmp(e Decimal) int { var dp, ep decParts - if _, nan := checkNan(d, e, &dp, &ep); nan { + if _, nan := checkNan2(d, e, &dp, &ep); nan { return -2 } return cmp(d, e, &dp, &ep) @@ -68,7 +68,7 @@ func (d Decimal) Cmp(e Decimal) int { // If d or e is NaN, it returns a corresponding NaN result. func (d Decimal) CmpDec(e Decimal) Decimal { var dp, ep decParts - if nan, is := checkNan(d, e, &dp, &ep); is { + if nan, is := checkNan2(d, e, &dp, &ep); is { return nan } switch cmp(d, e, &dp, &ep) { @@ -215,7 +215,7 @@ func (d Decimal) CopySign(e Decimal) Decimal { // Rounding rules are applied as per the context. func (ctx Context) Quo(d, e Decimal) Decimal { var dp, ep decParts - if nan, is := checkNan(d, e, &dp, &ep); is { + if nan, is := checkNan2(d, e, &dp, &ep); is { return nan } var ans decParts @@ -312,19 +312,19 @@ func (d Decimal) Sqrt() Decimal { // Add computes d + e func (ctx Context) Add(d, e Decimal) Decimal { var dp, ep decParts - if nan, is := checkNan(d, e, &dp, &ep); is { + if checkFinite2(d, e, &dp, &ep) { + return ctx.add(d, e, &dp, &ep) + } + if nan, is := checkNan2(d, e, &dp, &ep); is { return nan } - if dp.fl == flInf || ep.fl == flInf { - if dp.fl != flInf { - return e.noSigInf() - } - if ep.fl != flInf || ep.sign == dp.sign { - return d.noSigInf() - } - return QNaN + if dp.fl != flInf { + return e.noSigInf() + } + if ep.fl != flInf || ep.sign == dp.sign { + return d.noSigInf() } - return ctx.add(d, e, &dp, &ep) + return QNaN } // noSigInf returns the same inf but with all ignored bits set to zero. @@ -334,6 +334,12 @@ func (d Decimal) noSigInf() Decimal { // Add computes d + e func (ctx Context) add(d, e Decimal, dp, ep *decParts) Decimal { + if dp.exp == ep.exp && dp.sign == ep.sign { + if sig := dp.significand.lo + ep.significand.lo; sig < 10*decimalBase { + dp.significand.lo = sig + return dp.decimal() + } + } if dp.significand.lo == 0 { return e } else if ep.significand.lo == 0 { @@ -453,7 +459,7 @@ func (ctx Context) FMA(d, e, f Decimal) Decimal { // Mul computes d * e. func (ctx Context) Mul(d, e Decimal) Decimal { var dp, ep decParts - if nan, is := checkNan(d, e, &dp, &ep); is { + if nan, is := checkNan2(d, e, &dp, &ep); is { return nan } var ans decParts @@ -585,7 +591,7 @@ var ( ) func (ctx Context) roundRefRaw(d, e Decimal, dp, ep *decParts) Decimal { - if nan, is := checkNan(d, e, dp, ep); is { + if nan, is := checkNan2(d, e, dp, ep); is { return nan } if dp.fl == flInf || ep.fl == flInf { diff --git a/d64/math_test.go b/d64/math_test.go index 70912ab..8236107 100644 --- a/d64/math_test.go +++ b/d64/math_test.go @@ -13,6 +13,8 @@ func checkDecimalBinOp( expected func(a, b int64) int64, actual func(a, b Decimal) Decimal, ) { + t.Helper() + for i := int64(-100); i <= 100; i++ { a := NewFromInt64(i) for j := int64(-100); j <= 100; j++ { From 42bfb9de191b6c6c4e7e061d0e03180ecce52232 Mon Sep 17 00:00:00 2001 From: Marcelo Cantos <13160581+anzdaddy@users.noreply.github.com> Date: Thu, 7 Aug 2025 13:54:32 +1000 Subject: [PATCH 3/6] 2x faster uint128 division by 10**15 and 10**16 --- d64/divconst_test.go | 86 ++++++++++++++++++++++++++++++++++++++++++++ d64/math.go | 7 ++-- d64/math_test.go | 26 ++++++++++++++ d64/uint128.go | 63 +++++++++++++++++++++++++++++--- 4 files changed, 174 insertions(+), 8 deletions(-) create mode 100644 d64/divconst_test.go diff --git a/d64/divconst_test.go b/d64/divconst_test.go new file mode 100644 index 0000000..9ca5e65 --- /dev/null +++ b/d64/divconst_test.go @@ -0,0 +1,86 @@ +package d64 + +import ( + "fmt" + "math/bits" + "math/rand" + "testing" +) + +const ( + base = 10_000_000_000_000_000 + tenBase = 10 * base + limit = tenBase * tenBase + limitHi = limit / (1 << 64) + limitLo = limit % (1 << 64) +) + +func TestU128_divrem_10_15(t *testing.T) { + t.Parallel() + testU128_divrem(t, u128_div_10_15, 1_000_000_000_000_000) +} + +func TestU128_divrem_10_16(t *testing.T) { + t.Parallel() + testU128_divrem(t, u128_div_10_16, 10_000_000_000_000_000) +} + +func testU128_divrem(t *testing.T, div func(hi, lo uint64) uint64, d uint64) { + t.Helper() + + test := func(hi, lo uint64) func(t *testing.T) { + return func(t *testing.T) { + t.Helper() + q := div(hi, lo) + Q, _ := bits.Div64(hi, lo, d) + if q != Q { + t.Fatalf("U128_div_10_16(%016x_%016x) = %d (%016[3]x), want %d (%016[4]x)", + hi, lo, q, Q) + } + } + } + t.Run("1", test(0, 0)) + t.Run("2", test(0, 1)) + t.Run("3", test(0, 10_000_000_000_000_000)) + t.Run("4", test(0, 20_000_000_000_000_000)) + t.Run("5", test( + 10_000_000_000_000_000_000_000/(1<<64), + 10_000_000_000_000_000_000_000%(1<<64), + )) + t.Run("6", test(1, 20_000_000_000_000_000)) + + r := rand.New(rand.NewSource(0)) + n := 10_000_000 + if testing.Short() { + n = 100_000 + } + for i := 0; i < n; i++ { + // Ensure hi:lo < 10^32. + hi := r.Uint64() % limitHi + lo := r.Uint64() % limitLo + if hi == limitHi { + lo %= limitLo + } + t.Run(fmt.Sprintf("rand[%d]", i), test(hi, lo)) + } +} + +var globalUint64 uint64 + +func BenchmarkDiv64_10_16(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + hi := uint64(i * 5421010862428) + lo := uint64(i) + globalUint64 = u128_div_10_16(hi, lo) + } +} + +func BenchmarkBitsDiv64_10_16(b *testing.B) { + b.ReportAllocs() + for i := 0; i < b.N; i++ { + hi := uint64(i) + lo := uint64(i) + globalUint64, _ = bits.Div64(hi, lo, 10_000_000_000_000_000) + } +} diff --git a/d64/math.go b/d64/math.go index 82059ea..6b10170 100644 --- a/d64/math.go +++ b/d64/math.go @@ -359,7 +359,6 @@ func (ctx Context) add(d, e Decimal, dp, ep *decParts) Decimal { dp, ep = ep, dp sep = -sep } - var rndStatus discardedDigit switch { case sep == 0: ans.add64(dp, ep) @@ -368,13 +367,13 @@ func (ctx Context) add(d, e Decimal, dp, ep *decParts) Decimal { dp.exp -= sep ans.add64(dp, ep) default: - dp.significand.mul64(&dp.significand, tenToThe[17]) + dp.significand.mul64(&dp.significand, 100_000_000_000_000_000) // 10¹⁷ dp.exp -= 17 - ep.significand.mul64(&ep.significand, tenToThe[17-sep]) + ep.significand.umul64(ep.significand.lo, tenToThe[17-sep]) ep.exp -= 17 - sep ans.add128V2(dp, ep) } - rndStatus = ans.roundToLo() + rndStatus := ans.roundToLo() if ans.exp < -expOffset { rndStatus = ans.rescale(-expOffset) } diff --git a/d64/math_test.go b/d64/math_test.go index 8236107..850a21a 100644 --- a/d64/math_test.go +++ b/d64/math_test.go @@ -495,6 +495,32 @@ func benchmarkDecimalData() []Decimal { MustParse("9945678e100"), NewFromInt64(1234567), NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), + NewFromInt64(-42), MustParse("3456789e-120"), } } diff --git a/d64/uint128.go b/d64/uint128.go index b7114de..adc496f 100644 --- a/d64/uint128.go +++ b/d64/uint128.go @@ -61,9 +61,9 @@ func (a *uint128T) sub(x, y *uint128T) *uint128T { func (a *uint128T) divrem64(x *uint128T, d uint64) uint64 { var r uint64 if x.hi == 0 { - a.lo, r = x.lo/d, x.lo%d + a.hi, a.lo, r = 0, x.lo/d, x.lo%d } else { - a.hi, r = bits.Div64(0, x.hi, d) + a.hi, r = x.hi/d, x.hi%d a.lo, r = bits.Div64(r, x.lo, d) } return r @@ -71,16 +71,71 @@ func (a *uint128T) divrem64(x *uint128T, d uint64) uint64 { // divbase divides a by [decimalBase]. func (a *uint128T) divbase(x *uint128T) *uint128T { - a.divrem64(x, decimalBase) + a.hi, a.lo = 0, u128_div_10_15(x.hi, x.lo) return a } +// Fast division by 10**15 +func u128_div_10_15(hi, lo uint64) uint64 { + if hi == 0 { + return lo / 1_000_000_000_000_000 + } + const M = 5575186299632655785383929569 + return u128_div(hi, lo, M/(1<<64), M%(1<<64)) +} + // div10base divides a by 10*[decimalBase]. func (a *uint128T) div10base(x *uint128T) *uint128T { - a.divrem64(x, 10*decimalBase) + a.hi, a.lo = 0, u128_div_10_16(x.hi, x.lo) return a } +// Fast division by 10**16 +func u128_div_10_16(hi, lo uint64) (q uint64) { + if hi == 0 { + return lo / 10_000_000_000_000_000 + } + const M = 557518629963265578538392957 + return u128_div(hi, lo, M/(1<<64), M%(1<<64)) +} + +// u128_div supports u128_div_10_15 and u128_div_10_16. It is not validated for any other value of M. +// M is computed with the following Python code from Hacker's Delight §10-15 https://doc.lagout.org/security/Hackers%20Delight.pdf: +// +// def magicgu(nmax, d): +// from math import log +// nc = (nmax//d)*d - 1 +// nbits = int(log(nmax, 2)) + 1 +// for p in range(0, 2*nbits + 1): +// if 2**p > nc*(d - 1 - (2**p - 1)%d): +// m = (2**p + d - 1 - (2**p - 1)%d)//d +// return (m, p) +// raise ValueError("Can't find p, something is wrong.") +// +// >>> magicgu((10**32-1)//2**15, 5**15) +// (5575186299632655785383929569, 127) +// >>> magicgu((10**32-1)//2**16, 5**16) +// (557518629963265578538392957, 126) +func u128_div(hi, lo, Mhi, Mlo uint64) uint64 { + // Values of M are chosen such that: + // - n/10**15 = M*(n/2¹⁵)>>127 + // - n/10**16 = M*(n/2¹⁶)>>126 + // Dividing by 2¹⁴, both become M*(n/2¹⁴)>>128, placing the result in the high word. + lo = hi<<50 | lo>>14 + hi >>= 14 + + // c:b:_ = hi:lo * Mhi:Mlo + b1, _ := bits.Mul64(lo, Mlo) + c2, b2 := bits.Mul64(hi, Mlo) + c3, b3 := bits.Mul64(lo, Mhi) + c4 := hi * Mhi + + b, carry1 := bits.Add64(b1, b2, 0) + _, carry2 := bits.Add64(b, b3, 0) + + return carry1 + carry2 + c2 + c3 + c4 +} + func (a *uint128T) lt(b *uint128T) bool { if a.hi != b.hi { return a.hi < b.hi From 66a6d82df9dd8fbefd6c3483401640544ad57c94 Mon Sep 17 00:00:00 2001 From: Marcelo Cantos <13160581+anzdaddy@users.noreply.github.com> Date: Fri, 8 Aug 2025 11:01:31 +1000 Subject: [PATCH 4/6] faster slow tests --- d64/divconst_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d64/divconst_test.go b/d64/divconst_test.go index 9ca5e65..97718d2 100644 --- a/d64/divconst_test.go +++ b/d64/divconst_test.go @@ -50,7 +50,7 @@ func testU128_divrem(t *testing.T, div func(hi, lo uint64) uint64, d uint64) { t.Run("6", test(1, 20_000_000_000_000_000)) r := rand.New(rand.NewSource(0)) - n := 10_000_000 + n := 1_000_000 if testing.Short() { n = 100_000 } From 4feeb78953fc4d51f46717660e146f87c3dd8d8f Mon Sep 17 00:00:00 2001 From: Marcelo Cantos <13160581+anzdaddy@users.noreply.github.com> Date: Fri, 8 Aug 2025 11:11:31 +1000 Subject: [PATCH 5/6] Intel EULA diff --git a/reftest/Intel-eula.txt b/reftest/Intel-eula.txt new file mode 100644 index 0000000..b9c93b7 --- /dev/null +++ b/reftest/Intel-eula.txt @@ -0,0 +1,30 @@ +The following EULA applies to files herein with an Intel copyright notice. +Source: https://www.netlib.org/misc/intel/ (IntelRDFPMathLib20U3.tar.gz) +-------------------------------------------------------------------------------- +Copyright (c) 2007-2024, Intel Corp. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. --- reftest/Intel-eula.txt | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 reftest/Intel-eula.txt diff --git a/reftest/Intel-eula.txt b/reftest/Intel-eula.txt new file mode 100644 index 0000000..b9c93b7 --- /dev/null +++ b/reftest/Intel-eula.txt @@ -0,0 +1,30 @@ +The following EULA applies to files herein with an Intel copyright notice. +Source: https://www.netlib.org/misc/intel/ (IntelRDFPMathLib20U3.tar.gz) +-------------------------------------------------------------------------------- +Copyright (c) 2007-2024, Intel Corp. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + * 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. + * Neither the name of Intel Corporation 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 COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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. From e1ad6c83d15c04d47bf2f50d980b9fb24279f2ff Mon Sep 17 00:00:00 2001 From: Marcelo Cantos <13160581+anzdaddy@users.noreply.github.com> Date: Fri, 8 Aug 2025 11:14:45 +1000 Subject: [PATCH 6/6] fix 32-bit build error --- d64/divconst_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d64/divconst_test.go b/d64/divconst_test.go index 97718d2..4ab9066 100644 --- a/d64/divconst_test.go +++ b/d64/divconst_test.go @@ -70,7 +70,7 @@ var globalUint64 uint64 func BenchmarkDiv64_10_16(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - hi := uint64(i * 5421010862428) + hi := uint64(i) * uint64(5421010862428) lo := uint64(i) globalUint64 = u128_div_10_16(hi, lo) }