Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [floating-point]

Approximate representation of numbers as a fixed number of digits multiplied by a logarithmic scale.

3
votes
3answers
56 views

Guarantees on computing $a+x(b-a)$ in floating point

I want to implement the function $f(x,a,b) = a + x(b-a)$ where all the inputs are floating point (doubles, say), such that (a) $f(0,a,b)=a$ exactly; (b) $f(1,a,b)=b$ exactly; (c) $f(x,a,b) \le f(y,a,b)...
0
votes
0answers
20 views

How does normalised floating point binary work with two's complement?

I'm doing AQA a-level computer science, and the specification for which states that: Exam questions on floating point numbers will use a format in which both the normalised mantissa and exponent are ...
1
vote
0answers
9 views

Where can I find some free benchmarks to evaluate a MCU? [closed]

At present, I'm designing a soft processor with single-precision floating point unit (FPU). I am going to put my soft core into an FPGA and do some performance evaluation. The benchmarks are supposed ...
0
votes
2answers
40 views

Float number to binary

I would like to convert 0,347 and 0,9828 to binary, how can I do that? I know that sucessive multiplication by 2 can do this, but this method seems very painful and even ineffective since the size of ...
2
votes
0answers
49 views

Stable and fast computation of the squared euclidean distance matrix

Let's say I want to compute the matrix $M$ of the squared euclidean distances between each pair of vectors $(x, y)$ belonging to two sets $X$ and $Y$ respectively. The sets of vectors $X$ and $Y$ have ...
4
votes
2answers
140 views

Proof that (x-y)(x+y) is more accurate than x²-y²

I was carrying on my reading of What Every Computer Scientist Should Know About Floating-Point Arithmetic but got stuck on the proof of Theorem 2 (page 34). At some point it says: \begin{align} (x \...
2
votes
1answer
45 views

Proof that a guard digit bound the error of subtraction

I was reading What Every Computer Scientist Should Know About Floating-Point Arithmetic, which is extremely interesting. But I have some troubles understanding the proof of Theorem 9 (page 33). First ...
0
votes
1answer
50 views

Why isn't it necessary to store an integer part of significant in IEEE754 floating point notation?

We see that there is a sign, exponent, and mantissa part for the notation. But, there is no location for the significant bit. Why isn't it necessary to store an integer part of significant in IEEE754 ...
-2
votes
1answer
36 views

Doubt in definition of Float

Can anyone tell the meaning of the bold portion? Float: It is used to store decimal numbers (numbers with floating point value) with single precision.
7
votes
5answers
568 views

Number of FLOPs (floating point operations) for exponentiation

What is the number of floating point operations needed to perform exponentiation (power of)? Assuming multiplication of two floats use one FLOP, the number of operations for $x^n$ will be $n-1$. ...
0
votes
2answers
43 views

How to test for overflow when multiplying floats

I am trying to implement a 3-term recurrence relation: $$ p_{n+1} = ap_n + bp_{n-1} $$ This can be implemented as ...
0
votes
1answer
24 views

How does IEEE 754 decimal encoding work? [closed]

This may be a silly question, but if a computer works in binary how can you encript numbers using decimal?
5
votes
0answers
81 views

What is the state of the algorithmic art for floating point arithmetic on complex numbers?

Most modern compilers and processors implement the IEEE 754 binary formats for floating point numbers. IEEE 754 guarantees that the addition, subtraction, multiplication, division, and square root ...
1
vote
1answer
51 views

Binary Floating Point Range/Precision for 4-bit Mantissa and 4-bit Exponent

I'm trying to understand binary floating point and using just a 4-bit mantissa and a 4-bit exponent (both 2s compliment) to keep things simple. As far as I can tell, the largest denary number I can ...
0
votes
1answer
25 views

Floating point precision from rearranging equation

When I run $x^2 - y^2$ with x=8.8888888888 and y=9.9999999999 in python, I get the following result: ...
1
vote
1answer
36 views

Why do I get different results from two calculation methods?

I am wondering what the reason for the following is We know that , exponential has a taylor representation : $$exp(x)=1+x+\frac{x^{2}}{2!}+\frac{x^{3}}{3!}+...$$ Using the first n terms , in R , ...
1
vote
2answers
49 views

Increased rounding relative error when subtracting

I'm reading the book "Lessons in Scientific Computing" by Schoerghofer and it says: If x and y are real numbers of the same sign, their sum x + y has an absolute error that adds the two ...
0
votes
3answers
83 views

IEEE754 representation in hexadecimal?

In class, I've heard hexadecimal representation for IEEE754 mentioned and described in 32bit length as a format that consists of one bit for sign, normalized 6-digit fraction (with an implied leading ...
1
vote
1answer
38 views

Addition errors in IEEE754 floating point representation

So in class, we were talking about the idea of floating point precision in IEEE754 format, and how, when some numbers are added, precision is lost. My professor then gave the following example of a ...
0
votes
0answers
418 views

Understanding denormalized numbers in floating point representation

I am confused about how denormalized numbers work in floating point representation. I was referring to Stallings book and this article. The book initially explains floating point number format in ...
1
vote
0answers
41 views

Accuracy and performance between a division and subtraction for a ratio in decibels

For comparing two images, one can use the Peak Signal-to-Noise Ratio (PSNR) metric, defined as follows: $\mathrm{PSNR} = 10 \cdot \log_{10}\left(\frac{\mathrm{MAX}^2}{\mathrm{MSE}}\right) = 20 \cdot \...
0
votes
0answers
23 views

Numbers lying between single and double precision

The IEEE floating point number format is defined as $$s\underbrace{c_1\dots c_m}_\text{exponent}\underbrace{f_1\dots f_n}_\text{fraction}\text{ (*)}$$ with $s, c_i, f_j$ being either $1$ or $0$. The ...
0
votes
0answers
20 views

IEEE-754 and machine numbers

I've been trying to wrap my head around machine numbers like the unit roundoff (u) and epsilon (e) in combination with the IEEE 754 standard. My textbook states some things that don't really make ...
2
votes
2answers
80 views

Algorithm challenge: build a pile of 'n' cubes whose total volume adds up to 'm'

I'm working on solving an algorithm problem defined as follows (important parts in bold): Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a ...
0
votes
1answer
28 views

algorithm for correctly rounded floating point radix conversion

Is there any generic algorithm which implements a floating point radix conversion? Lets say we have a $p$-digit FP number $A = \sum_{i=0}^{p-1} A_i \beta^{e-i}$ in radix $\beta$ and with $0 \leq ...
1
vote
0answers
108 views

Why is the method of im2col with GEMM is more efficient than the method of direction implementation with SIMD in CNN

The convolutional layers are most computationally intense parts of Convolutional neural networks (CNNs).Currently the common approach to impement convolutional layers is to expand the image into a ...
0
votes
1answer
45 views

Floating point Euclidean norm optimization

Past few days I've been struggling with floating point number exercises, trying to learn how they work and what are their limitations. The exercise I've encountered today is as follows: The ...
0
votes
1answer
69 views

How to compute relative error for the rounding of floating point numbers when the rounded number is 0?

I have asked this question on Stack Overflow, I am asking it here in the hope to get more traction. The relative rounding error for a floating point number x is defined as $e_r = |\frac{(round(x) -...
2
votes
2answers
51 views

Double floating precision exercise

today I had to deal with this exercise: If $x \approx y$, we might expect some cancellation in computing $log(x)- log(y)$. On the other hand, $log(x) - log(y) = log(\frac{x}{y})$, and the latter ...
0
votes
1answer
32 views

Floating point number fractions excercise

During my preparation for an exam, I've come across an exercise that was focused on precision calculation with floating point numbers. It goes like this: Consider the expression : $$\frac{1}{1-x}-\...
0
votes
1answer
82 views

Using a 16-bit 2,s Complement normalised floating-point representation; 10-bit fractional mantissa and a 6-bit integer exponent: express 2.171875

So far I know how to normalize when you are given, say: 1111010010 Mantissa, and 000100 exponent and are told that it's a positive number: ...
1
vote
1answer
23 views

Number of IEEE 754 doubles between two adjacent single-precision floats

Between an adjacent pair of nonzero IEEE single precision real numbers, how many IEEE double precision numbers are there? I was also wondering if this question has something to do with the hidden ...
0
votes
1answer
54 views

Why are floats converted from different integers sometimes equal?

I'm trying to understand the following algorithm: ...
0
votes
2answers
29 views

Can area-partitioning lose included points due to floating point precision?

I'm currently partitioning a big area $A$ into $n$ areas $B_i$ such that $$\bigcup_{i=1}^n B_i = A$$ I have geo-coordinates which I know are in $A$ (also with the finite precision of floats). ...
1
vote
2answers
48 views

Hypothetical question on floating point normalization

I've seen a few questions posted regarding the upsides/downsides of floating point formats that have explicit integrals vs. formats that have implicit integrals, but have not seen an answer that ...
1
vote
1answer
69 views

Algorithm for implementing the modulus “%” operator?

How can an efficient modulus operator be implemented? Here's a naive way of defining A % B: given $(a,b) \in \mathbb{Z}$ (represented as ...
1
vote
3answers
58 views

How does computer store non-repeating decimal very accurately?

Maybe it is not accurate at all, but it looks very accurate for me. I'm making a scientific calculator for my portfolio, and I found an interesting phenomenon. Because computers store decimals not ...
0
votes
0answers
34 views

Using half float to represent scaled short (int16), do I lose precision comparing to using double?

A device is generating 14-bit integer which is stored as int16 (short), a scaling process will then scale the data to value of order 10E-3. Does it then matter if I store these number with half float ...
2
votes
1answer
42 views

Implementing Gauss–Legendre algorithm using arbitrary-length rationals

I am trying to re-implement SuperPI myself in Rust, but the results I get are not very accurate. SuperPI computes pi using the Gauss-Legendre algorithm. The Gauss–Legendre algorithm is quite simple, ...
2
votes
1answer
411 views

How to calculate machine epsilon

In a binary system we know that the next floating point number after 4 is 4+1/32. What is the machine epsilon? Is it 1/32 and if yes, why?
1
vote
1answer
64 views

What does floating point biased notation have to do with 2's complement?

During lecture the professor talked about Integer Compare for floats and kept mentioning two's complement. What's the relation between them? All I understand is that two's complement can take us ...
0
votes
0answers
10 views

Why does economising the power series give me more error?

Suppose I want to economise $\sin x$ with the following taylor series: $$P_{2n-1}(x) = \sum^n_{i=1}(-1)^{i-1}\frac{x^{2i-1}}{(2i-1)!}$$ for the interval $[-1, 1]$ for $P_5(x)$. For $P_5(x)$, I have ...
0
votes
1answer
76 views

Computing the error bound of floating-point expression

How should I compute the maximum absolute and relative error of the following IEEE-754 floating-point expression? a.y + (x - a.x) * ((b.y - a.y) / (b.x - a.x)) ...
3
votes
1answer
68 views

Understanding truncation and rounding error in IEEE floating point system?

I'm trying to understand the theory behind finding the optimal $h$ value for differentiation in this definition: $$ \frac{f(x+h) - f(x)}{h}$$ as $h$ tends to 0. Here is my understanding: ...
1
vote
1answer
355 views

How to Add IEEE 754 Floating Point Numbers

I'm trying to add two 16 bit numbers that use a similar format as IEEE 754. The format is in the image below: I can't figure out how to add together two numbers for the life of me. Specifically, ...
3
votes
1answer
50 views

Why do I get really different results with my benchmarking code I made?

I'm doing research work for my last year in high school. My work is about processors and for the experimental part i've coded an app that can mesure how many Floating Point Operation can a processor ...
4
votes
1answer
84 views

Imaginary numbers and negative zero

I've been studying the low-level hardware implementations of floating point numbers and doing an exercise to design a custom floating point implementation. I know that being able to represent ...
1
vote
2answers
257 views

Is IEEE 754 float arithmetic associative, commutative, distributive, etc? Why?

Does the associative/commutative/distributive/etc property hold for arithmetic performed with IEEE 754 floats? Obviously the answer is no to most of those questions, but do any of the properties of ...
4
votes
2answers
51 views

Union of fixed and floating point types

Say I have two real number types. They may be floating or fixed point. How can I construct a new type whose values are at least the union of the two with the minimal number of bits? There are 3 cases ...
1
vote
4answers
102 views

Float multiplication

While doing the multiplication 1.4*0.8 in a python program, I got the result as 1.1199999999999999. Why didn't I get ...