Author Topic: intel decimal math library  (Read 6434 times)

0 Members and 1 Guest are viewing this topic.

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
intel decimal math library
« on: April 03, 2022, 11:31:04 am »
here's a small test of the Intel decimal math library https://www.intel.com/content/www/us/en/developer/articles/tool/intel-decimal-floating-point-math-library.html, if there's enough interest I may expand the function declarations
Code: QB64: [Select]
  1.  
  2.     Function __bid_strtod64~&& (s$, Byval ptr&)
  3.     Function add64~&& Alias "__bid64_add" (ByVal x~&&, Byval y~&&, Byval rnd_mode&, flag&)
  4.     Function sub64~&& Alias "__bid64_sub" (ByVal x~&&, Byval y~&&, Byval rnd_mode&, flag&)
  5.     Function mul64~&& Alias "__bid64_mul" (ByVal x~&&, Byval y&&, Byval rnd_mode&, flag&)
  6.     Function div64~&& Alias "__bid64_div" (ByVal x~&&, Byval y~&&, Byval rnd_mode&, flag&)
  7.  
  8.     Function is_equal64& Alias "__bid64_quiet_equal" (ByVal x~&&, Byval y~&&, flag&)
  9.     Function is_less64& Alias "__bid64_quiet_less" (ByVal x~&&, Byval y~&&, flag&)
  10.     Function is_greater64& Alias "__bid64_quiet_greater" (ByVal x~&&, Byval y~&&, flag&)
  11.     Function is_less_equal64& Alias "__bid64_quiet_less_equal" (ByVal x~&&, Byval y~&&, flag&)
  12.     Function is_greater_equal64& Alias "__bid64_quiet_greater_equal" (ByVal x~&&, Byval y~&&, flag&)
  13.     Function is_unequal64& Alias "__bid64_quiet_not_equal" (ByVal x~&&, Byval y~&&, flag&)
  14.     Function isZero64& Alias "__bid64_isZero" (ByVal x~&&)
  15.     Sub __bid64_to_string (ps$, Byval x~&&, pf&)
  16.     Function copy64~&& Alias "__bid64_copy" (ByVal x~&&)
  17.     Function negate64~&& Alias "__bid64_negate" (ByVal x~&&)
  18.     Function abs64~&& Alias "__bid64_abs" (ByVal x~&&)
  19.     Function sqrt64~&& Alias "__bid64_sqrt" (ByVal x~&&, Byval rnd_mode&, flag&)
  20.     Function cbrt64~&& Alias "__bid64_cbrt" (ByVal x~&&, Byval rnd_mode&, flag&)
  21.     Function sin64~&& Alias "__bid64_sin" (ByVal x~&&, Byval rnd_mode&, flag&)
  22.     Function cos64~&& Alias "__bid64_cos" (ByVal x~&&, Byval rnd_mode&, flag&)
  23.     Function tan64~&& Alias "__bid64_tan" (ByVal x~&&, Byval rnd_mode&, flag&)
  24.     Function asin64~&& Alias "__bid64_asin" (ByVal x~&&, Byval rnd_mode&, flag&)
  25.     Function acos64~&& Alias "__bid64_acos" (ByVal x~&&, Byval rnd_mode&, flag&)
  26.     Function atan64~&& Alias "__bid64_atan" (ByVal x~&&, Byval rnd_mode&, flag&)
  27.     Function sinh64~&& Alias "__bid64_sinh" (ByVal x~&&, Byval rnd_mode&, flag&)
  28.     Function cosh64~&& Alias "__bid64_cosh" (ByVal x~&&, Byval rnd_mode&, flag&)
  29.     Function tanh64~&& Alias "__bid64_tanh" (ByVal x~&&, Byval rnd_mode&, flag&)
  30.     Function asinh64~&& Alias "__bid64_asinh" (ByVal x~&&, Byval rnd_mode&, flag&)
  31.     Function acosh64~&& Alias "__bid64_acosh" (ByVal x~&&, Byval rnd_mode&, flag&)
  32.     Function atanh64~&& Alias "__bid64_atanh" (ByVal x~&&, Byval rnd_mode&, flag&)
  33.     Function atan264~&& Alias "__bid64_atan2" (ByVal x~&&, Byval y~&&, Byval rnd_mode&, flag&)
  34.     Function hypot64~&& Alias "__bid64_hypot" (ByVal x~&&, Byval y~&&, Byval rnd_mode&, flag&)
  35.     Function log1064~&& Alias "__bid64_log10" (ByVal x~&&, Byval rnd_mode&, flag&)
  36.     Function exp1064~&& Alias "__bid64_exp10" (ByVal x~&&, Byval rnd_mode&, flag&)
  37.     Function log64~&& Alias "__bid64_log" (ByVal x~&&, Byval rnd_mode&, flag&)
  38.     Function exp64~&& Alias "__bid64_exp" (ByVal x~&&, Byval rnd_mode&, flag&)
  39.     Function pow64~&& Alias "__bid64_pow" (ByVal x~&&, Byval y~&&, Byval rnd_mode&, flag&)
  40.     Function log264~&& Alias "__bid64_log2" (ByVal x~&&, Byval rnd_mode&, flag&)
  41.     Function exp264~&& Alias "__bid64_exp2" (ByVal x~&&, Byval rnd_mode&, flag&)
  42.     Function erf64~&& Alias "__bid64_erf" (ByVal x~&&, Byval rnd_mode&, flag&)
  43.     Function erfc64~&& Alias "__bid64_erfc" (ByVal x~&&, Byval rnd_mode&, flag&)
  44.     Function tgamma64~&& Alias "__bid64_tgamma" (ByVal x~&&, Byval rnd_mode&, flag&)
  45.     Function lgamma64~&& Alias "__bid64_lgamma" (ByVal x~&&, Byval rnd_mode&, flag&)
  46.     Function floor64l& Alias "__bid64_to_int32_floor" (ByVal x~&&, flag&)
  47.     Function ceil64l& Alias "__bid64_to_int32_ceil" (ByVal x~&&, flag&)
  48.     Function floor64ul~& Alias "__bid64_to_uint32_floor" (ByVal x~&&, flag&)
  49.     Function ceil64ul~& Alias "__bid64_to_uint32_ceil" (ByVal x~&&, flag&)
  50.     Function floor64ll~&& Alias "__bid64_to_int64_floor" (ByVal x~&&, flag&)
  51.     Function ceil64ll~&& Alias "__bid64_to_int64_ceil" (ByVal x~&&, flag&)
  52.     Function floor64ull~&& Alias "__bid64_to_uint64_floor" (ByVal x~&&, flag&)
  53.     Function ceil64ull~&& Alias "__bid64_to_uint64_ceil" (ByVal x~&&, flag&)
  54.     Function tosingle64! Alias "__bid64_to_binary32" (ByVal x~&&, Byval rnd_mode&, flag&)
  55.     Function todouble# Alias "__bid64_to_binary64" (ByVal x~&&, Byval rnd_mode&, flag&)
  56.     Function singleto64~&& Alias "__binary32_to_bid64" (ByVal x As Single, Byval rnd_mode&, flag&)
  57.     Function doubleto64~&& Alias "__binary64_to_bid64" (ByVal x As Double, Byval rnd_mode&, flag&)
  58.  
  59. Dim As Long flag, rm
  60.  
  61. rm = 0
  62. i = strto64("-1")
  63. y = strto64("1")
  64. z = strto64(".1")
  65. While is_less_equal64(i, y, flag)
  66.     Print tostring(i)
  67.     i = add64(i, z, rm, flag)
  68.  
  69. Function strto64~&& (s As String)
  70.     Dim As String sn
  71.     sn = s + Chr$(0)
  72.     strto64~&& = __bid_strtod64(sn, 0)
  73.  
  74.     Dim As Long ex, ex1, i, ln
  75.     Dim As String s, sd, sdl, sdr, se, sign
  76.     Dim As _Unsigned _Integer64 one, x
  77.     Dim As Long flag, rm
  78.     If isZero64(z) Then
  79.         tostring = " 0"
  80.         Exit Function
  81.     End If
  82.     rm = 0
  83.     x = z
  84.     one = __bid_strtod64("1.00000000000000000000", 0)
  85.     s = Space$(256)
  86.     __bid64_to_string s, mul64(x, one, 0, flag), flag
  87.     sd = _Trim$(s)
  88.     ln = Len(sd)
  89.     i = InStr(sd, "E")
  90.     sdl = Left$(sd, i - 1)
  91.     ex = Val(Mid$(sd, i + 1))
  92.     ln = Len(sdl)
  93.     If ex = 0 Then
  94.         sd = sdl
  95.     ElseIf ex > 0 Or ex < 0 Then
  96.         ex1 = ln + ex - 2
  97.         If ex1 >= 0 And ex1 < (ln - 1) Then
  98.             sd = Left$(sdl, ex1 + 2) + "." + Mid$(sdl, ex1 + 3)
  99.         ElseIf ex1 < 0 And ex1 > -5 Then
  100.             sign = Left$(sd, 1)
  101.             sd = sign + "0." + String$(Abs(ex1) - 1, "0") + Mid$(sdl, 2)
  102.         Else
  103.             se = _Trim$(Str$(ex1))
  104.             If ex1 > 0 Then
  105.                 se = "+" + se
  106.             End If
  107.             sd = sdl
  108.             sdl = Left$(sd, 2)
  109.             sdr = Mid$(sd, 3)
  110.             sd = sdl + "." + sdr + "E" + se
  111.         End If
  112.     End If
  113.     If Left$(sd, 1) = "+" Then
  114.         sd = " " + Mid$(sd, 2)
  115.     End If
  116.     tostring = sd
  117.  
here's the 64-bit dll
* libbid.zip (Filesize: 3.1 MB, Downloads: 372)
« Last Edit: April 03, 2022, 01:18:31 pm by jack »

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: intel decimal math library
« Reply #1 on: April 03, 2022, 09:33:25 pm »
the Intel math library has 3 types decimal32, decimal64 and decimal128
the decimal64 is easy to use in QB64 but for the decimal128 I had make a wrapper
Code: QB64: [Select]
  1. Type BID_UINT128
  2.  
  3.     Sub binary64_to_bid128 (result As BID_UINT128, x As Double, Byval rnd_mode~&, pfpsf~&)
  4.     Sub binary80_to_bid128 (result As BID_UINT128, x As _Float, Byval rnd_mode~&, pfpsf~&)
  5.     Sub bid128_add (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  6.     Sub bid128_sub (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  7.     Sub bid128_mul (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  8.     Sub bid128_div (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  9.     Sub bid128_sqrt (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  10.     Sub bid128_cbrt (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  11.     Sub bid128_exp (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  12.     Sub bid128_log (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  13.     Sub bid128_pow (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  14.     Sub bid128_atan2 (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  15.     Sub bid128_fmod (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  16.     Sub bid128_modf (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  17.     Sub bid128_hypot (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  18.     Sub bid128_sin (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  19.     Sub bid128_cos (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  20.     Sub bid128_tan (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  21.     Sub bid128_asin (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  22.     Sub bid128_acos (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  23.     Sub bid128_atan (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  24.     Sub bid128_sinh (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  25.     Sub bid128_cosh (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  26.     Sub bid128_tanh (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  27.     Sub bid128_asinh (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  28.     Sub bid128_acosh (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  29.     Sub bid128_atanh (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  30.     Sub bid128_log1p (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  31.     Sub bid128_expm1 (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  32.     Sub bid128_log10 (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  33.     Sub bid128_log2 (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  34.     Sub bid128_exp2 (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  35.     Sub bid128_exp10 (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  36.     Sub bid128_erf (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  37.     Sub bid128_erfc (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  38.     Sub bid128_tgamma (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  39.     Sub bid128_lgamma (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  40.     Function bid128_quiet_equal& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  41.     Function bid128_quiet_greater& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  42.     Function bid128_quiet_greater_equal& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  43.     Function bid128_quiet_greater_unordered& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  44.     Function bid128_quiet_less& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  45.     Function bid128_quiet_less_equal& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  46.     Function bid128_quiet_less_unordered& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  47.     Function bid128_quiet_not_equal& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  48.     Function bid128_quiet_not_greater& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  49.     Function bid128_quiet_not_less& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  50.     Function bid128_quiet_ordered& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  51.     Function bid128_quiet_unordered& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  52.     Function bid128_signaling_greater& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  53.     Function bid128_signaling_greater_equal& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  54.     Function bid128_signaling_greater_unordered& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  55.     Function bid128_signaling_less& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  56.     Function bid128_signaling_less_equal& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  57.     Function bid128_signaling_less_unordered& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  58.     Function bid128_signaling_not_greater& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  59.     Function bid128_signaling_not_less& (x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  60.  
  61.     Sub bid128_copy (result As BID_UINT128, x As BID_UINT128)
  62.     Sub bid128_negate (result As BID_UINT128, x As BID_UINT128)
  63.     Sub bid128_abs (result As BID_UINT128, x As BID_UINT128)
  64.     Sub bid128_to_string (S As String, x As BID_UINT128, pfpsf~&)
  65.     Function bid128_to_binary32! (x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  66.     Function bid128_to_binary64# (x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  67.     Function bid128_to_binary80## (x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  68.     Sub bid_strtod128 (result As BID_UINT128, ps_in As String, Byval endptr&)
  69.  
  70.     Function bid128_to_int8_rnint%% (x As BID_UINT128, pfpsf~&)
  71.     Function bid128_to_int8_xrnint%% (x As BID_UINT128, pfpsf~&)
  72.     Function bid128_to_int8_rninta%% (x As BID_UINT128, pfpsf~&)
  73.     Function bid128_to_int8_xrninta%% (x As BID_UINT128, pfpsf~&)
  74.     Function bid128_to_int8_int%% (x As BID_UINT128, pfpsf~&)
  75.     Function bid128_to_int8_xint%% (x As BID_UINT128, pfpsf~&)
  76.     Function bid128_to_int8_floor%% (x As BID_UINT128, pfpsf~&)
  77.     Function bid128_to_int8_xfloor%% (x As BID_UINT128, pfpsf~&)
  78.     Function bid128_to_int8_ceil%% (x As BID_UINT128, pfpsf~&)
  79.     Function bid128_to_int8_xceil%% (x As BID_UINT128, pfpsf~&)
  80.  
  81.     Function bid128_to_int16_rnint% (x As BID_UINT128, pfpsf~&)
  82.     Function bid128_to_int16_xrnint% (x As BID_UINT128, pfpsf~&)
  83.     Function bid128_to_int16_rninta% (x As BID_UINT128, pfpsf~&)
  84.     Function bid128_to_int16_xrninta% (x As BID_UINT128, pfpsf~&)
  85.     Function bid128_to_int16_int% (x As BID_UINT128, pfpsf~&)
  86.     Function bid128_to_int16_xint% (x As BID_UINT128, pfpsf~&)
  87.     Function bid128_to_int16_floor% (x As BID_UINT128, pfpsf~&)
  88.     Function bid128_to_int16_xfloor% (x As BID_UINT128, pfpsf~&)
  89.     Function bid128_to_int16_ceil% (x As BID_UINT128, pfpsf~&)
  90.     Function bid128_to_int16_xceil% (x As BID_UINT128, pfpsf~&)
  91.  
  92.     Function bid128_to_uint8_rnint~%% (x As BID_UINT128, pfpsf~&)
  93.     Function bid128_to_uint8_xrnint~%% (x As BID_UINT128, pfpsf~&)
  94.     Function bid128_to_uint8_rninta~%% (x As BID_UINT128, pfpsf~&)
  95.     Function bid128_to_uint8_xrninta~%% (x As BID_UINT128, pfpsf~&)
  96.     Function bid128_to_uint8_int~%% (x As BID_UINT128, pfpsf~&)
  97.     Function bid128_to_uint8_xint~%% (x As BID_UINT128, pfpsf~&)
  98.     Function bid128_to_uint8_floor~%% (x As BID_UINT128, pfpsf~&)
  99.     Function bid128_to_uint8_xfloor~%% (x As BID_UINT128, pfpsf~&)
  100.     Function bid128_to_uint8_ceil~%% (x As BID_UINT128, pfpsf~&)
  101.     Function bid128_to_uint8_xceil~%% (x As BID_UINT128, pfpsf~&)
  102.  
  103.     Function bid128_to_uint16_rnint~% (x As BID_UINT128, pfpsf~&)
  104.     Function bid128_to_uint16_xrnint~% (x As BID_UINT128, pfpsf~&)
  105.     Function bid128_to_uint16_rninta~% (x As BID_UINT128, pfpsf~&)
  106.     Function bid128_to_uint16_xrninta~% (x As BID_UINT128, pfpsf~&)
  107.     Function bid128_to_uint16_int~% (x As BID_UINT128, pfpsf~&)
  108.     Function bid128_to_uint16_xint~% (x As BID_UINT128, pfpsf~&)
  109.     Function bid128_to_uint16_floor~% (x As BID_UINT128, pfpsf~&)
  110.     Function bid128_to_uint16_xfloor~% (x As BID_UINT128, pfpsf~&)
  111.     Function bid128_to_uint16_ceil~% (x As BID_UINT128, pfpsf~&)
  112.     Function bid128_to_uint16_xceil~% (x As BID_UINT128, pfpsf~&)
  113.  
  114.     Function bid128_to_int32_rnint& (x As BID_UINT128, pfpsf~&)
  115.     Function bid128_to_int32_xrnint& (x As BID_UINT128, pfpsf~&)
  116.     Function bid128_to_int32_rninta& (x As BID_UINT128, pfpsf~&)
  117.     Function bid128_to_int32_xrninta& (x As BID_UINT128, pfpsf~&)
  118.     Function bid128_to_int32_int& (x As BID_UINT128, pfpsf~&)
  119.     Function bid128_to_int32_xint& (x As BID_UINT128, pfpsf~&)
  120.     Function bid128_to_int32_floor& (x As BID_UINT128, pfpsf~&)
  121.     Function bid128_to_int32_xfloor& (x As BID_UINT128, pfpsf~&)
  122.     Function bid128_to_int32_ceil& (x As BID_UINT128, pfpsf~&)
  123.     Function bid128_to_int32_xceil& (x As BID_UINT128, pfpsf~&)
  124.  
  125.     Function bid128_to_uint32_rnint~& (x As BID_UINT128, pfpsf~&)
  126.     Function bid128_to_uint32_xrnint~& (x As BID_UINT128, pfpsf~&)
  127.     Function bid128_to_uint32_rninta~& (x As BID_UINT128, pfpsf~&)
  128.     Function bid128_to_uint32_xrninta~& (x As BID_UINT128, pfpsf~&)
  129.     Function bid128_to_uint32_int~& (x As BID_UINT128, pfpsf~&)
  130.     Function bid128_to_uint32_xint~& (x As BID_UINT128, pfpsf~&)
  131.     Function bid128_to_uint32_floor~& (x As BID_UINT128, pfpsf~&)
  132.     Function bid128_to_uint32_xfloor~& (x As BID_UINT128, pfpsf~&)
  133.     Function bid128_to_uint32_ceil~& (x As BID_UINT128, pfpsf~&)
  134.     Function bid128_to_uint32_xceil~& (x As BID_UINT128, pfpsf~&)
  135.  
  136.     Function bid128_to_int64_rnint&& (x As BID_UINT128, pfpsf~&)
  137.     Function bid128_to_int64_xrnint&& (x As BID_UINT128, pfpsf~&)
  138.     Function bid128_to_int64_rninta&& (x As BID_UINT128, pfpsf~&)
  139.     Function bid128_to_int64_xrninta&& (x As BID_UINT128, pfpsf~&)
  140.     Function bid128_to_int64_int&& (x As BID_UINT128, pfpsf~&)
  141.     Function bid128_to_int64_xint&& (x As BID_UINT128, pfpsf~&)
  142.     Function bid128_to_int64_floor&& (x As BID_UINT128, pfpsf~&)
  143.     Function bid128_to_int64_xfloor&& (x As BID_UINT128, pfpsf~&)
  144.     Function bid128_to_int64_ceil&& (x As BID_UINT128, pfpsf~&)
  145.     Function bid128_to_int64_xceil&& (x As BID_UINT128, pfpsf~&)
  146.  
  147.     Function bid128_to_uint64_rnint~&& (x As BID_UINT128, pfpsf~&)
  148.     Function bid128_to_uint64_xrnint~&& (x As BID_UINT128, pfpsf~&)
  149.     Function bid128_to_uint64_rninta~&& (x As BID_UINT128, pfpsf~&)
  150.     Function bid128_to_uint64_xrninta~&& (x As BID_UINT128, pfpsf~&)
  151.     Function bid128_to_uint64_int~&& (x As BID_UINT128, pfpsf~&)
  152.     Function bid128_to_uint64_xint~&& (x As BID_UINT128, pfpsf~&)
  153.     Function bid128_to_uint64_floor~&& (x As BID_UINT128, pfpsf~&)
  154.     Function bid128_to_uint64_xfloor~&& (x As BID_UINT128, pfpsf~&)
  155.     Function bid128_to_uint64_ceil~&& (x As BID_UINT128, pfpsf~&)
  156.     Function bid128_to_uint64_xceil~&& (x As BID_UINT128, pfpsf~&)
  157.  
  158.     Sub bid128_round_integral_exact (result As BID_UINT128, x As BID_UINT128, Byval rnd_mode~&, pfpsf~&)
  159.     Sub bid128_round_integral_nearest_even (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  160.     Sub bid128_round_integral_negative (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  161.     Sub bid128_round_integral_positive (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  162.     Sub bid128_round_integral_zero (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  163.     Sub bid128_round_integral_nearest_away (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  164.     Sub bid128_nextup (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  165.     Sub bid128_nextdown (result As BID_UINT128, x As BID_UINT128, pfpsf~&)
  166.     Sub bid128_nextafter (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  167.     Sub bid128_minnum (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  168.     Sub bid128_minnum_mag (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  169.     Sub bid128_maxnum (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  170.     Sub bid128_maxnum_mag (result As BID_UINT128, x As BID_UINT128, y As BID_UINT128, pfpsf~&)
  171.     Sub bid128_from_int32 (result As BID_UINT128, Byval x&)
  172.     Sub bid128_from_uint32 (result As BID_UINT128, Byval x~&)
  173.     Sub bid128_from_int64 (result As BID_UINT128, Byval x&&)
  174.     Sub bid128_from_uint64 (result As BID_UINT128, Byval x~&&)
  175.     Function bid128_isSigned& (x As BID_UINT128)
  176.     Function bid128_isNormal& (x As BID_UINT128)
  177.     Function bid128_isSubnormal& (x As BID_UINT128)
  178.     Function bid128_isFinite& (x As BID_UINT128)
  179.     Function bid128_isZero& (x As BID_UINT128)
  180.     Function bid128_isInf& (x As BID_UINT128)
  181.     Function bid128_isSignaling& (x As BID_UINT128)
  182.     Function bid128_isCanonical& (x As BID_UINT128)
  183.     Function bid128_isNaN& (x As BID_UINT128)
  184.  
  185.  
  186.  
  187. Dim As BID_UINT128 i, y, z, x
  188. Dim As Long flag, rm
  189.  
  190. rm = 0
  191. bid128_from_int32 i, -1 'strto128 i, "1"
  192. bid128_from_int32 y, 1 'strto128 y, "20"
  193. strto128 z, ".1"
  194. While bid128_quiet_less_equal(i, y, flag)
  195.     'bid128_sin x, i, rm, flag
  196.     'bid128_asin x, x, rm, flag
  197.     'bid128_log10 x, i, rm, flag
  198.     'Print d128tostring$(x)
  199.     Print d128tostring$(i)
  200.     bid128_add i, i, z, rm, flag
  201.  
  202. Sub strto128 (result As BID_UINT128, s As String)
  203.     Dim As String sn
  204.     sn = s + Chr$(0)
  205.     bid_strtod128 result, sn, 0
  206.  
  207. Function d128tostring$ (z As BID_UINT128)
  208.     Dim As Long ex, ex1, i, ln
  209.     Dim As String s, sd, sdl, sdr, se, sign
  210.     Dim As BID_UINT128 one, x
  211.     Dim As Long flag, rm
  212.     If bid128_isZero(z) Then
  213.         d128tostring = " 0"
  214.         Exit Function
  215.     End If
  216.     rm = 0
  217.     x = z
  218.     bid128_copy x, z
  219.     bid_strtod128 one, "1.00000000000000000000000000000000000", 0
  220.     s = Space$(256)
  221.     bid128_mul x, x, one, 0, flag
  222.     bid128_to_string s, x, flag
  223.     sd = _Trim$(s)
  224.     ln = Len(sd)
  225.     i = InStr(sd, "E")
  226.     sdl = Left$(sd, i - 1)
  227.     ex = Val(Mid$(sd, i + 1))
  228.     ln = Len(sdl)
  229.     If ex = 0 Then
  230.         sd = sdl
  231.     ElseIf ex > 0 Or ex < 0 Then
  232.         ex1 = ln + ex - 2
  233.         If ex1 >= 0 And ex1 < (ln - 1) Then
  234.             sd = Left$(sdl, ex1 + 2) + "." + Mid$(sdl, ex1 + 3)
  235.         ElseIf ex1 < 0 And ex1 > -5 Then
  236.             sign = Left$(sd, 1)
  237.             sd = sign + "0." + String$(Abs(ex1) - 1, "0") + Mid$(sdl, 2)
  238.         Else
  239.             se = _Trim$(Str$(ex1))
  240.             If ex1 > 0 Then
  241.                 se = "+" + se
  242.             End If
  243.             sd = sdl
  244.             sdl = Left$(sd, 2)
  245.             sdr = Mid$(sd, 3)
  246.             sd = sdl + "." + sdr + "E" + se
  247.         End If
  248.     End If
  249.     If Left$(sd, 1) = "+" Then
  250.         sd = " " + Mid$(sd, 2)
  251.     End If
  252.     d128tostring = sd
  253.  

the 64-bit dll

output
Code: [Select]
-1.000000000000000000000000000000000
-0.9000000000000000000000000000000000
-0.8000000000000000000000000000000000
-0.7000000000000000000000000000000000
-0.6000000000000000000000000000000000
-0.5000000000000000000000000000000000
-0.4000000000000000000000000000000000
-0.3000000000000000000000000000000000
-0.2000000000000000000000000000000000
-0.1000000000000000000000000000000000
 0
 0.1000000000000000000000000000000000
 0.2000000000000000000000000000000000
 0.3000000000000000000000000000000000
 0.4000000000000000000000000000000000
 0.5000000000000000000000000000000000
 0.6000000000000000000000000000000000
 0.7000000000000000000000000000000000
 0.8000000000000000000000000000000000
 0.9000000000000000000000000000000000
 1.000000000000000000000000000000000

Press any key to continue
« Last Edit: April 07, 2022, 01:55:16 pm by jack »

Offline jack

  • Seasoned Forum Regular
  • Posts: 408
    • View Profile
Re: intel decimal math library
« Reply #2 on: April 05, 2022, 09:55:53 pm »
updated the code and dll, many functions added