Description: Cos(pi()/2) returns 6,12323399573677E-17, but should return 0 Steps to Reproduce: 1. put to cell formula =cos(pi()/2) 2. 3. Actual Results: Cos(pi()/2) returns 6,12323399573677E-17 Expected Results: cos(pi()/2) should return 0 Reproducible: Always User Profile Reset: No Additional Info: OpenGL is off, OpenCL is ON and supported by hardware (nvidia quadro K1000M)
Reproduced in Version: 6.3.0.0.beta1+ Build ID: 4abdaf4afb2245d404f6709124b3c627b07b8a3c CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US Calc: threaded and back to LibreOffice 3.3.0 OOO330m19 (Build:6) tag libreoffice-3.3.0.4 @Eike, @Winfried, I thought you might be interested in this issue...
Nope, that's correct and expected. Calc (or better computers in general) doesn't calculate with infinite precision (it uses floating points internally) so there are cases, where a calculation will produce an (rounding) error. So in cases like this you need to round things to the nearest decimal (=ROUND) - with that you also define how much precision you can tolerate.
Thank you for reporting the bug but i cannot reproduce with Version: 6.2.4.2 Build ID: 2412653d852ce75f65fbfa83fb7e7b669a126d64 CPU threads: 8; OS: Linux 4.19; UI render: default; VCL: gtk3; Locale: nl-BE (en_US.UTF-8); UI-Language: en-US Calc: threaded Version: 6.4.0.0.alpha0+ Build ID: c27e92b29efe573e2cda9844e9ca38965f502443 CPU threads: 8; OS: Linux 4.19; UI render: default; VCL: gtk3; Locale: nl-BE (en_US.UTF-8); UI-Language: en-US Calc: threaded can reproduce with 6.1 ==> 6.2.3.2 Can you upgrade LO to 6.2.4.2 and retest
cos(pi()/2) = sin(0) but sin(0) returns 0 and cos(pi()/2) returns 6,12323399573677E-17
Please notice, that spreadsheets always do mathematics numerically. If you need symbolic mathematics, a spreadsheet is the wrong tool. In that case you should use a computer algebra system.
It was an example. An answer to @Tomaz Vajngerl that it is not correct. If you put formula =sin(0) calc will return 0, but if you put formula =cos(pi()/2) you will get 6,12323399573677E-17 @Regina Henschel It is treated purely numerically. @all cos(pi()/2) = sin(0) This is not symbolic calculation, this is paradigm. If you write this paradigm as formula then it will return FALSE, but should be TRUE Other tested formula was =cos(pi()/2)-sin(0), it will return -6,12323399573677E-17 , but should return 0.
(In reply to Xavier Van Wijmeersch from comment #3) > Thank you for reporting the bug but i cannot reproduce with > > Version: 6.2.4.2 > Build ID: 2412653d852ce75f65fbfa83fb7e7b669a126d64 > CPU threads: 8; OS: Linux 4.19; UI render: default; VCL: gtk3; > Locale: nl-BE (en_US.UTF-8); UI-Language: en-US > Calc: threaded > > Version: 6.4.0.0.alpha0+ > Build ID: c27e92b29efe573e2cda9844e9ca38965f502443 > CPU threads: 8; OS: Linux 4.19; UI render: default; VCL: gtk3; > Locale: nl-BE (en_US.UTF-8); UI-Language: en-US > Calc: threaded > > can reproduce with 6.1 ==> 6.2.3.2 > > Can you upgrade LO to 6.2.4.2 and retest Upgraded, tested and reproduced with 6.2.4.2
(In reply to abra01 from comment #6) > It was an example. An answer to @Tomaz Vajngerl that it is not correct. > If you put formula =sin(0) calc will return 0, but if you put formula > =cos(pi()/2) you will get 6,12323399573677E-17 sin(0) is 0 because 0 can be represented exactly in a computer. Pi can't - it's a irrational number and is in a computer an approximate constant to the number of available precision of the floating point type. So then you divide that approximation by 2 which again deviates from the true value of pi/2. Lastly cos in computer is also a function that's computed numerically (calculating a Taylor series if I remember correctly) and has an error. Mostly this is not visible and pretty much irrelevant because the error is small, but sometimes (like in this) the result is surprising, but as I said - expected.
There have been bugs like this in the past, but we can't do nothing about it. BTW excel produces the same error, as it too is using IEEE 754 floating point numbers in the calculation core.