Re: [Tinycc-devel] Major bug in the pow function resulting in: 0.993013 = 0.860892

2024-01-05 Thread Steffen Nurpmeso
Vincent Lefevre wrote in
 <20240105235600.gd4...@qaa.vinc17.org>:
 |On 2024-01-05 13:47:25 +0100, Aurélie Tisson (BastaPrint) wrote:
 |> The same calculation gives me 2 different values : 0.993013 0.860892
 |> wheras it should give 0.993013 only (tells GCC).
 |
 |Well, your code is not portable.

You are the mathematician.
But *i* thought it was a request to release 0.9.28, given that tcc
of 20231230 gets the stuff correct?

 |> #include  
 |> #include  
 |> int main(){ 
 |> double s = .7; 
 |> double a = (1. - .1 * s) / (1. + .1 * s); 
 |  ^^^ ^^^
 |> double b = pow(a, .05); 
 |> double c = pow( ((1. - .1 * s) / (1. + .1 * s)), .05); 
 |^^^ ^^^
 |
 |> printf("%f %f \n", b, c); 
 |>} 
 |
 |You should not depend on contraction of FP expressions.
 |Here, GCC may generate a FMA, which generally increases
 |the accuracy of the results.

I am overly happy there is no floating-point in my code.
Never in the past, not today.  (Anything which was there was
thrown away.)  Yay.

--steffen
|
|Der Kragenbaer,The moon bear,
|der holt sich munter   he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Major bug in the pow function resulting in: 0.993013 = 0.860892

2024-01-05 Thread Vincent Lefevre
Hi,

On 2024-01-05 13:47:25 +0100, Aurélie Tisson (BastaPrint) wrote:
> The same calculation gives me 2 different values : 0.993013 0.860892
> wheras it should give 0.993013 only (tells GCC).

Well, your code is not portable.

> #include  
> #include  
> int main(){ 
> double s = .7; 
> double a = (1. - .1 * s) / (1. + .1 * s); 
  ^^^ ^^^
> double b = pow(a, .05); 
> double c = pow( ((1. - .1 * s) / (1. + .1 * s)), .05); 
^^^ ^^^

> printf("%f %f \n", b, c); 
> } 

You should not depend on contraction of FP expressions.
Here, GCC may generate a FMA, which generally increases
the accuracy of the results.

-- 
Vincent Lefèvre  - Web: 
100% accessible validated (X)HTML - Blog: 
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Major bug in the pow function resulting in: 0.993013 = 0.860892

2024-01-05 Thread Fred van Kempen via Tinycc-devel
 Hello:
> ==> can anyone reproduce this?I tried your code with Visual Studio (2019), 
> CLang (17.0.6), MinGW-w64 (GCC 13.1.0) and,of course TCC. All compilers 
> produce the expected result:
  P:\>tcc -o pow.exe pow.c
  P:\>pow
  0.993013   0.993013
  P:\>tcc -v
  tcc version 0.9.28rc 2023-12-09_main@8332f68* (i386 Windows)

Could you try 0.9.28rc to see if its "gone" on your end too?
Fred
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel