3
$\begingroup$

Definitions/Notation: Fix positive integers $b$ and $M$. Consider the set of real numbers which can be exactly expressed with $2M+1$ coefficients in base $b$, defined by $$\mathcal{X}(b,M):=\{x\in \mathbb{R}:\, (\exists s\in \{0,1\})\,(\exists c_{-M},\dots,c_M\in \{0,\dots,b-1\}\, x=(-1)^s \sum_{i=-M}^M c_i b^i\}.$$
Further, consider the coefficient set $B_M:=\{0,\dots,b-1\}^M\times \{0,\dots b-1\}^{M+1} \times \{0,1\} $, with the "floating point-type identification" $$ \mathcal{X}(b,M)\ni x = (-1)^s\sum_{i=-M}^M c_i b^i \mapsto \big( (c_i)_{i=-M}^{-1} , (c_i)_{i=0}^{M} , \operatorname{sgn}(x) \big) $$
where $\operatorname{sgn}(x):=I_{x\ge 0}$ identifies if $x$ is positive or negative; i.e.\ $\operatorname{sgn}(x)=s$ in the above representation determines the negativity/positivity of $x$, $(c_i)_{i=-M}^{-1}$ are the coefficients for the fractional part of $|x|$ in $[0,1)$ and $ (c_i)_{i=0}^{M}$ are the coefficients for the integer part of $|x|$.

Example/Note: For instance, if $b=2$, then this defines numbers with a finite-length binary expansion.


I'm looking for a reference book that rigorously provides algorithms and computational complexity (space and time) estimates for implementation: addition, multiplication, division, exponentiation, etc...(other "elementary operations)) on elements of $\mathcal{X}(b,M)$ in terms of their coefficient "representations" in $B_M$.

Unfortunately, everything I've come across just gives numerical examples or example code... (I'm obviously looking in the wrong place but I just don't know where to look).

$\endgroup$

1 Answer 1

3
$\begingroup$

In cryptography, one often needs to implement modular (and polynomial) arithmetic $\mathbb{Z}/N\mathbb{Z}$, but your hardware only natively supports computations in $\mathbb{Z}/n\mathbb{Z}$. Typical choices of $(N, n)$ are things like

  • $\log_2 N\geq 2048$ (RSA), or $\log_2 N\approx 500$ (ECC), or $\log_2 N\leq 40$ (lattices, though one typically needs polynomial arithmetic for these), and
  • $\log_2 n \in\{64,128\}$ (desktops), $\log_2 n\in\{32,64\}$ (phones), and $\log_2 n\in\{8,16\}$ (embedded).

For this reason, cryptographers often treat a problem fairly similar to yours quite carefully. The standard (though now somewhat dated) reference is Chapter 14 of "The Handbook of Applied Cryptography" by Menzes et. al. The paper Multiplying Polynomials without Powerful Multiplication Instructions is more recent, and while it is (in the end) focused on polynomial arithmetic, it contains sections and references more focused on the case of modular arithmetic, e.g. Sections 2.5 and 3.1.

$\endgroup$
5
  • $\begingroup$ Perhaps a silly question, but why is the arithmetic modular? I mean, for instance (omitting signs) if $x=a+b2+c/2$ then with $1=a=b=c$ then I was thinking that $x+x=x$ (the maximal value). Alternatively, how should I think of standard arithmetic being modular (I mean the rollover bit)? $\endgroup$
    – ABIM
    Commented Nov 21 at 3:17
  • 1
    $\begingroup$ That's why I said "similar to yours". What you mention can be one (for example, in Rust this is known as saturating addition), but it's not obviously the best choice. If you have a finite subset $S$, and $+_{\mathsf{sat}}$ saturating addition, it is simple to see that $(S, +_{\mathsf{sat}})$ is not a group (the maximal value $x$ is not invertible). $\endgroup$ Commented Nov 21 at 3:34
  • 1
    $\begingroup$ As for standard arithmetic, there are various types of "modular" arithmetic. Throughout I'll include sources to the relevant Rust. You can have "silent" modular arithmetic (wrapping add), arithmetic that returns a special failure type None if overflow occurs checked_add, arithmetic that returns the "wrapped" value, as well as (effectively) $\endgroup$ Commented Nov 21 at 3:39
  • 1
    $\begingroup$ a carry bit indicating if wrapping occurred overflowing_add, your type of arithmetic (mentioned before). $\endgroup$ Commented Nov 21 at 3:39
  • 2
    $\begingroup$ I think this is one of the best answers I've ever gotten on MO (counting your comments)! $\endgroup$
    – ABIM
    Commented Nov 21 at 4:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .