Skip to content
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

Absolute value of negative zero returns negative zero should be positive zero #4787

Open
speechfreedoms opened this issue Feb 3, 2025 · 0 comments · May be fixed by #4797
Open

Absolute value of negative zero returns negative zero should be positive zero #4787

speechfreedoms opened this issue Feb 3, 2025 · 0 comments · May be fixed by #4797

Comments

@speechfreedoms
Copy link

minimal example

package test
import "core:fmt"
import "core:math"
main :: proc() {
	k := -0.0
	fmt.printfln("abs(-0.0) = %v", math.abs(k)) // abs(-0.0) = -0
}

provides incorrect answer to absolute value of negative zero, should be +0

https://en.wikipedia.org/wiki/Absolute_value
https://en.m.wikipedia.org/wiki/Signed_zero
https://www.calculatorsoup.com/calculators/algebra/absolute-value-calculator.php

compiler command

odin run . or odin build .

system info

Odin 2025-01
Windows
LLVM 18.1.8

suggested labels

incorrect results
bug (possibly?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant