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

math.big: Incorrect division with negative numbers #19585

Closed
elliotchance opened this issue Oct 17, 2023 · 0 comments · Fixed by #19587
Closed

math.big: Incorrect division with negative numbers #19585

elliotchance opened this issue Oct 17, 2023 · 0 comments · Fixed by #19587
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@elliotchance
Copy link
Contributor

elliotchance commented Oct 17, 2023

Describe the bug

Division involving negative numbers may have incorrect rounding.

Reproduction Steps

module main

import math.big

fn main() {
	// Correct: 123
	println(big.integer_from_int(1234) / big.integer_from_int(10))

	// Incorrect: -124
	println(big.integer_from_int(-1234) / big.integer_from_int(10))

	// Correct: -123
	println(big.integer_from_int(1234) / big.integer_from_int(-10))

	// Incorrect: 124
	println(big.integer_from_int(-1234) / big.integer_from_int(-10))
}

Expected Behavior

123
-123
-123
123

Current Behavior

123
-124
-123
124

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.2 4bc9a8f.f54f156

Environment details (OS name and version, etc.)

V full version: V 0.4.2 4bc9a8f.f54f156
OS: macos, macOS, 12.6, 21G115
Processor: 10 cpus, 64bit, little endian, Apple M1 Max

getwd: /Users/elliot/Library/Mobile Documents/comappleCloudDocs/Development/github.com/elliotchance/vsql
vexe: /Users/elliot/Downloads/v-5/v
vexe mtime: 2023-10-15 18:52:03

vroot: OK, value: /Users/elliot/Downloads/v-5
VMODULES: OK, value: /Users/elliot/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.37.0 (Apple Git-136)
Git vroot status: weekly.2023.41-18-gf54f156d (7 commit(s) behind V master)
.git/config present: true

CC version: Apple clang version 14.0.0 (clang-1400.0.29.102)
thirdparty/tcc status: thirdparty-macos-amd64 46662e2

Note

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs.
Projects
None yet
1 participant