Top "Precision" questions

For questions related to numerical precision in programming.

Equals operator for zeros (BigDecimal / Double) in Java

A few interesting observations w.r.t equals operator on 0 and 0.0 new Double(0.0).equals(0) returns false, while new Double(0.0).equals(0.0) …

java double precision bigdecimal zero
Loss of precision - int -> float or double

I have an exam question I am revising for and the question is for 4 marks. "In java we can assign …

java floating-point double precision
How to print a double with full precision on iOS?

Test case: NSLog(@"%f", M_PI); NSLog(@"%@", [NSString stringWithFormat:@"%f", M_PI]); NSLog(@"%@", [NSNumber numberWithDouble:M_PI]); Results: 3.141593 3.141593 3.141592653589793 Conclusions: 1) Printing …

iphone cocoa-touch double precision nslog
GNU Octave, round a number to units precision

In GNU Octave version 3.4.3 I want to round a matrix to 2 units precision on the contents of a matrix like …

linux matrix rounding precision octave
Why are floating point numbers inaccurate?

Why do some numbers lose accuracy when stored as floating point numbers? For example, the decimal number 9.2 can be expressed …

floating-point language-agnostic precision
Golang floating point precision float32 vs float64

I wrote a program to demonstrate floating point error in Go: func main() { a := float64(0.2) a += 0.1 a -= 0.3 var i …

go floating-point precision
What is the precision of long double in C++?

Does anyone know how to find out the precision of long double on a specific platform? I appear to be …

c++ precision long-double
PI and accuracy of a floating-point number

A single/double/extended-precision floating-point representation of Pi is accurate up to how many decimal places?

floating-point precision floating-accuracy
Set back default floating point print precision in C++

I want to control the precision for a double during a comparison, and then come back to default precision, with …

c++ floating-point default precision rounding
C# double to decimal precision loss

I have a double "138630.78380386264" and I want to convert it to a decimal, however when I do so I do …

c# double decimal precision