Questions tagged [computer-arithmetic]

For questions about the particulars of doing math on computers, e.g. floating point numbers, over/underflow, implementing arithmetic operators/functions for binary numbers.

35 questions
57
votes
3 answers

Why is division so much more complex than other arithmetic operations?

I recently encountered a case where I needed an integer division operation on a chip that lacked one (ARM Cortex-A8). While trying to research why that must be, I found out that in general division takes many more cycles than addition, subtraction…
Phonon
  • 673
  • 1
  • 5
  • 8
11
votes
3 answers

Which is computed faster, $a^b$, $\log_a c$ or $\sqrt[b]{c}$?

Which is computed faster, $a^b$ or $\log_a c$ or $\sqrt[b]{c}$? $a$, $b$ and $c$ are positive reals with $b>1$. What kinds of algorithms will you use in the comparison? What are their complexities? For example, when $c \equiv a^b$ or $c \approx a^b$…
Tim
  • 1,281
  • 1
  • 12
  • 27
6
votes
2 answers

How many bits to unambiguously represent fixed-point division?

Suppose I have a function which divides an $m$-bit unsigned integer $a$ by an $n$-bit unsigned integer $b$ and returns the quotient as a fixed-point number with $t$ fractional bits, truncating towards zero. So I have $f(a,b)= 2^{-t}\lfloor…
Sneftel
  • 173
  • 6
5
votes
1 answer

How would I figure out when a function would be at the "brink of underflow"?

User hardmath, provided an excellent overview of how to handle overflow when calculating the product of two functions, where one is likely to overflow: https://scicomp.stackexchange.com/a/20913/9466 The answer also discusses special cases involving…
bzm3r
  • 669
  • 5
  • 21
3
votes
1 answer

Fibonacci, variation on the theme

I am trying to calculate the numbers $n$ for which the $n$-th Fibonacci number $F_n$ is a multiple of $n$; that is fib(n)%n==0. Here is the best PARI code I could come up with (for the counting…
user7632
1
vote
1 answer

What does this definition of two's complement representation of signed integers mean?

I am reading a book on digital circuits. It says that given a n-bit binary number $N$, its two's complement representation is itself, if $N$ is positive; and its two's complement representation is $2^n - N$, if $N$ is negative. It is unclear to me…
Tim
  • 1,281
  • 1
  • 12
  • 27
0
votes
1 answer

How many years it would take our laptops to be as fast as the fastest super computer in 2000

How many years it would take our laptops to be as fast as the fastest super computer in 2000 according to Moore's law?
Victor
  • 103
  • 4