Questions tagged [rounding]
25 questions
14
votes
1 answer
Floating point rounding
Can an IEEE-754 floating point number < 1 (i.e. generated with a random number generator which generates a number >= 0.0 and < 1.0) ever be multiplied by some integer (in floating point form) to get a number equal to or larger than that integer due…
Cade Roux
- 323
- 2
- 7
7
votes
3 answers
Why can't we round results of linear programming to get integer programming?
If linear programming suggests that we need $2.5$ trucks to deliver goods, why can't we round up and say $3$ trucks are needed?
If linear programming suggests we can afford only $3.7$ workers, then why can't we just round down to $3$ workers?
When…
Souradeep Nanda
- 279
- 2
- 14
4
votes
0 answers
Compile-time error control vs. interval arithmetic?
I use interval arithmetic for reliable computing. Now, a procedure coded in a good implementation of interval arithmetic takes perhaps about eight times as much as the same procedure carried out without interval arithmetic (if the lion's share of…
H A Helfgott
- 241
- 1
- 6
4
votes
1 answer
Are IEEE floating point numbers intervals or point values?
The context is IEEE 754-2008 floating point number systems. The systems defined by the standard comprise, as far as I understand it, a bit-level representation and a set of guarantees on the precision for a given number of computations.
Now, I am…
equaeghe
- 200
- 1
- 8
3
votes
1 answer
Normalizing the mantissa in floating point representation
How to represent $0.148 * 2^{14}$ in normalized floating point arithmetic with the format
1 - Sign bit
7 - Exponent in Excess-64 form
8 - Mantissa
$(0.148)_{10} = (0.00100101\;111...)_2$
We shift it 3 bits to left to make it normalized…
Shashwat
- 513
- 2
- 6
- 14
3
votes
0 answers
Understanding the proof of a Theorem in Knuth's TAOCP about floating-point addition and subtraction
This is about the proof of Theorem A on pg. 235 of Knuth's "The Art of Computer Programming" Vol. 2, 3rd Ed.
Background:
By "normalized floating point number" Knuth means a number of the form
\begin{equation}
\pm (0.a_1 \ldots a_p)_b \times b^e…
Simon
- 350
- 2
- 6
3
votes
4 answers
Batch rounding with preservation of a sum
I have a sequence of floating point numbers. I want to map each of them to one of their closest integers. There is one rule:
Sum of integers must be as close to the sum of original numbers as possible (ideally sum of integers is a rounded sum of…
Andrey Godyaev
- 297
- 1
- 9
3
votes
1 answer
Integrality gap and LP-rounding
I have a doubt about integrality gap.
If I know that there is no integrality gap for a given problem, i.e.:
$$\frac{\mathrm{OPT}(\mathrm{ILP})}{\mathrm{OPT}(\mathrm{LP})} = 1 \text{ (right?)},$$
then, does it have sense to do an…
bruce_springsteen
- 63
- 5
2
votes
0 answers
Normalised Floating Point System
I have a floating point number system and I have a number for which I need to calculate the exact relative error after rounding. The number is clearly an overflow. Does anyone know what I should do?
I've tried converting the number to from the…
user1804234
- 121
- 3
2
votes
1 answer
floating point rounding (1/x)*x
I'm trying to figure out what the smallest positive integer x such that the floating point expression round(round(1/x)*x) is not equal to 1 in single precision.
I have that the answer is 41, but when I let the number 3 for example be x, isn't 1/3 =…
user40377
- 21
- 1
2
votes
1 answer
1/2 Approximation to MAX-DICUT by rounding a linear program
Consider a graph $G=(V, A, w)$, where each arc $(u,v)\in A$ has a non negative weight $w_{u,v} \in \mathbb{R}^+$, partition $V$ into $U$ and $W$, $W=V-U$ such that $\sum_{(i,j)\in A} w_{i,j}z_{i,j}$ where $z_{i,j} = [[i\in U \land j \in W]]$.
By…
2
votes
0 answers
Integrality gap in Online Problems and adaptation to competitive ratio
As we all know, in offline problems it is common practice to calculate the integrality gap to get some bound on the approximation ratio of the integral solution.
Now this gap ($IG:=\frac{OPT_{frac}}{OPT_{int}}$) relies on the fact that we can…
Felix
- 161
- 8
1
vote
1 answer
Shortest decimal expansion within binary interval
Consider an interval $[x-2^n,x+2^n]$ defined by a binary float $x$ and a power of two $2^n$ typically much smaller than $x$. I would like to know whether an efficient algorithm exists to determine the shortest decimal expansion within the interval.…
equaeghe
- 200
- 1
- 8
1
vote
1 answer
Rounding logarithm to next integer — Potential function
The problem is IV-3 of this pdf: potential function.
Defining a potential function as $\Phi(i) = 2i - 2^{\lfloor{\log_2i}\rfloor+1} + 1$
The solution states that if $i$ is not an exact power of $2$, we have:
$$\Phi(i) = 2i - i + 1 .$$
This means…
joaoaccarvalho
- 47
- 4
1
vote
2 answers
Sampling from bins with ratio preservation
I have sequence of integers $a_1, a_2, .., a_n$,
let $S_a = \sum_{i=1}^{N}{a_i}$,
for any $k \in (0; 1)$ I need an algorthim to that maps every $a_i$ into another integer $b_i$ with 2 requirements:
$S_b = \sum_{i=1}^{N}{b_i}$ is as close as…
Andrey Godyaev
- 297
- 1
- 9