• January 28, 2022, 11:50:57 AM

Author Topic:  Fixed Arbitrary Precision and multiplication  (Read 153 times)

0 Members and 1 Guest are viewing this topic.

Offline superheal

  • Fractal Feline
  • **
  • Posts: 176
Fixed Arbitrary Precision and multiplication
« on: January 13, 2022, 04:38:06 PM »
I was reading through this: http://www.hpdz.net/TechInfo/Bignum.htm#General and I was also exploring MandelMachine's BigNum_Arb class, which is basically a fixed precision lib. I wanted to find some way to do the multiplication but I am kinda struggling. MM is probably doing the multiplication part on c or asm. It also has some other BigNum hardcoded precision obsolete classes that have multiplication implemented, but their data storing format seems different (If I stored the same number created in the arb class, on the fixed digits, the printed double value is wrong).

The format is an array of 64 bit longs , but only the 60 bits are used (4 bits are there for overflow).
[60bits] .decimal_point. [60bits][60bits][60bits]...
I have tried to make a small example with only 2 decimals in order to try the multiplication as described in http://www.hpdz.net/TechInfo/Bignum.htm#General
but I probably mess up the sub-products because the need twice as much bits to be calculated.

Does anyone have any experience on this?

Linkback: https://fractalforums.org/index.php?topic=4598.0

Offline marcm200

  • 3e
  • *****
  • Posts: 1111
Re: Fixed Arbitrary Precision and multiplication
« Reply #1 on: January 13, 2022, 07:08:17 PM »
The multiplication in the link is standard school math multiplication in base-10.

I implemented my own fixed precision number type, where I use digits to base 1 billion (which fit in 32 bit) and then multiplying two such numbers is performed after casting each digit to int64_t by multiplying one number with each of the digits of the 2nd one, shifting the sub-result an appropriate amount of digit positions (performed by tailing zeros after shifting as the fractional part is left-aligned and the integer part right-aligned), then adding with a fixed-number addition routine to the ongoing overall result respecting carry-over. That way I can reuse all tested and working routines.

I suspect you're doing the same. or are you using the presumed speed-up described in the article where some of the sub-products are not computed in the first place (when truncation is used as rounding mode) ?
(I'm not using any of those as my number type is intended for interval arithmetics and I perform outward rounding according to sign left or right interval end).
« Last Edit: January 13, 2022, 08:21:45 PM by marcm200, Reason: interval rounding description »


xx
Arbitrary Precision in GLSL and perturbation theory questions

Started by matigekunstintelligentie on Noob's Corner

1 Replies
378 Views
Last post June 08, 2020, 12:20:59 AM
by claude
clip
MandelRender: Optimized (some features removed), and arbitrary precision

Started by Mr Rebooted on Other

0 Replies
577 Views
Last post September 29, 2021, 12:26:24 AM
by Mr Rebooted
xx
(Fixed precision) floating point performance: Best datatype?

Started by marcm200 on Programming

18 Replies
1051 Views
Last post January 30, 2020, 08:11:23 PM
by marcm200
xx
UF extended/arbitrary precision

Started by FractalDave on UltraFractal

0 Replies
290 Views
Last post September 13, 2018, 06:14:36 PM
by FractalDave
xx
Arbitrary precision Java

Started by superheal on Programming

0 Replies
132 Views
Last post September 18, 2021, 07:55:18 PM
by superheal