-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
math.log10(10.0)
produces 0.9999999999999999
, instead of 1.0
, when compiled with -exclude @vlib/math/*.c.v
#23136
Comments
-exclude @vlib/math/*.c.v
math.log10(10.0)
produces 0.9999999999999999
, instead of 1.0
, when compiled with -exclude @vlib/math/*.c.v
Another way to reproduce the problem is by running this: import math
dump( math.log10(-0.00000000000000001) )
dump( math.log10(0.0) )
dump( math.log10(0.00000000000000001) )
dump( math.log10(1.0) )
dump( math.log10(10.0) )
dump( math.log10(100.0) )
dump( math.log10(1000.0) )
dump( math.log10(10000.0) )
dump( math.log10(1000000.0) )
dump( math.log10(10000000.0) )
dump( math.log10(100000000.0) ) with
While with the C libm wrappers, which are used by default, the same code produces:
|
Let alone logs, seems the print rounding affects somehow: const tens := {
'∞ ': f64(10)
'17': 9.99999999999999999
'16': 9.9999999999999999
'15': 9.999999999999999
'14': 9.99999999999999
}
fn main() {
for decimals, ten in tens {
println('${decimals} ${ten}')
}
} Result:
I mean, the print alone of fifteen decimals figure above modified last |
The |
Yes, this is what mister Golang said: package main
import (
"fmt"
"math"
)
func main() {
fmt.Println(math.Log10(10.0))
fmt.Println(9.999999999999999)
} Result
|
V doctor:
What did you do?
./v -g -o vdbg cmd/v && ./vdbg -exclude @vlib/math/*.c.v run math_log10_bug.v
What did you expect to see?
A working program, without a failing assertion, even with
./v -exclude @vlib/math/*.c.v run math_log10_bug.v
What did you see instead?
Note: without
-exclude @vlib/math/*.c.v
there is no issue, after #23129 .With it, the problem still remains, because in this case, the program uses the pure V approximation for the log function.
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
Huly®: V_0.6-21573
The text was updated successfully, but these errors were encountered: