[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Major bug in the pow function resulting in: 0.993013
From: |
Steffen Nurpmeso |
Subject: |
Re: [Tinycc-devel] Major bug in the pow function resulting in: 0.993013 = 0.860892 |
Date: |
Sat, 06 Jan 2024 01:12:18 +0100 |
User-agent: |
s-nail v14.9.24-585-g9999e323b6 |
Vincent Lefevre wrote in
<20240105235600.GD4789@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 <stdio.h>
|> #include <math.h>
|> 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)