Questions tagged [epsilon]

The machine epsilon gives an upper bound on the relative error due to rounding in floating point arithmetic. The quantity is also called "macheps" or "unit roundoff".

The IEEE standard does not define the terms machine epsilon and unit roundoff, so differing definitions of these terms are in use, which can cause some confusion.

The following different definition is much more widespread outside academia: Machine epsilon is defined as the smallest number that, when added to one, yields a result different from one.

158 questions
5
votes
1 answer

Choosing an Epsilon Value for Floating Point Comparisons

My team is working with financial software that exposes monetary values as C# floating point doubles. Occasionally, we need to compare these values to see if they equal zero, or fall under a particular limit. When I noticed unexpected behavior in…
Mark Bell
  • 384
  • 2
  • 8
5
votes
1 answer

How can I represent epsilon in a regular expression?

The text book teaches us to write regular expressions using the epsilon (ε) symbol, but how can I translate that symbol directly to code without having to completely rework my regular expression? For instance, how would I write this regex which…
ubiquibacon
  • 10,451
  • 28
  • 109
  • 179
5
votes
1 answer

Machine Epsilon precision discrepancy

I am attempting to calculate the machine epsilon value for doubles and floats in C++ as part of a school assignment. I'm using Cygwin in Windows 7, 64 bit, here is the code: #include int main() { double epsilon = 1; while(1 +…
JennaLewis
  • 51
  • 2
5
votes
3 answers

How to calculate machine epsilon in MATLAB?

I need to find the machine epsilon and I am doing the following: eps = 1; while 1.0 + eps > 1.0 do eps = eps /2; end However, it shows me this: Undefined function or variable 'do'. Error in epsilon (line 3) while 1.0 + eps > 1.0 do What…
Vzqivan
  • 361
  • 3
  • 6
  • 16
5
votes
2 answers

Is this a good solution for R#'s complaint about loss of precision?

There was some code in my project that compared two double values to see if their difference exceeded 0, such as: if (totValue != 1.0) Resharper complained about this, suggesting I should use "EPSILON" and added just such a constant to the code…
5
votes
4 answers

C++ next float with numeric_limits / epsilon?

Consider a "normal" real number TREAL x in C++ (not subnormal and not NaN/Infinite) (TREAL = float, double, long double) Is the following the good solution to find the previous and next x from a floating-point point of view ? TREAL xprev =…
Vincent
  • 57,703
  • 61
  • 205
  • 388
4
votes
0 answers

Switching entire network from float32 to float64 on condition

Since lower precision can yield significant computational time savings, I would like to be able to switch (mid run) all variables in my partially trained network from float32 to float64 on an error condition. For example: I initialize all variables…
user23590632
  • 91
  • 1
  • 3
4
votes
1 answer

Floating point less-than-equal comparisons after addition and substraction

Is there a "best practice" for less-than-equal comparisons with floating point number after a series of floating-point arithmetic operations? I have the following example in R (although the question applies to any language using floating-point). I…
4
votes
3 answers

Why my double can contain a value below the machine epsilon?

I was solving an equation using double precision and I got -7.07649e-17 as a solution instead of 0. I agree it's close enough that I can say it's equal but I've read that the machine epsilon for the C++ double type is 2^-52 which is larger than the…
Random Tourist
  • 151
  • 1
  • 1
  • 12
4
votes
1 answer

Browsersupport of Number.EPSILON?

I'd like to use the Number.EPSILON value in my application and was wondering how this is supported across different browsers. MDN states that it is supported by Firefox and Chrome but not by IE and Safari. I've tested it myself in the console of…
Fidel90
  • 1,828
  • 6
  • 27
  • 63
3
votes
3 answers

Float epsilon is different in c++ than c#

So small question, I've been looking into moving part of my C# code to C++ for performance reasons. Now when I look at my float.Epsilon in C# its value is different from my C++ value. In C# the value, as described by microsoft is 1.401298E-45. In…
Foitn
  • 604
  • 6
  • 25
3
votes
1 answer

Why the numeric_limits Machine Epsilon does not satisfy the 1+e>1 condition?

If I'm not wrong the definition of the Machine Epsilon is the lowest number that satisfies the condition: I was trying to test this making use of the std::numeric_limits::epsilon() but the value does not satisty this, if you try to get the…
3
votes
1 answer

How to decrease machine precision .Machine$double.eps in R?

When using an R package called did, I get this error: Error in solve.default(preV) : system is computationally singular: reciprocal condition number = 4.09946e-19 The solve function has an argument called tol whereby I can set the tolerance and…
3
votes
3 answers

How to determine if two doubles are nearly equal

I'm trying to find some Java code to determine if two doubles are nearly equal. I did a lot of Googling and found bits and pieces that I've put together here. Where it starts to escape me is the use of a "relative epsilon". This approach seems like…
careysb
  • 49
  • 1
  • 2
  • 7
3
votes
3 answers

Calculating closest numbers numpy

I'm trying to calculate the closest numbers to 0 but couldn't get what I want so far. I have a quite simple code; y = 0.0 x = 0.1 while (y + x > y): x = x/2.0 x*2 But I keep getting 0.0 as output. How can I fix this
ricster
  • 521
  • 2
  • 5
  • 16
1 2
3
10 11