Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

setVar fails if n > 15 #1

Open
Schmieta opened this issue Nov 22, 2020 · 0 comments
Open

setVar fails if n > 15 #1

Schmieta opened this issue Nov 22, 2020 · 0 comments

Comments

@Schmieta
Copy link

Hi all,

during unit-testing, I found the Cube.setVar method fails, if the var index exceeds 15.
Let the index loop up to 32 and do some setVar/getVar checks, then getVar(15) will fail.

`public void setVar(int n, int v) {`
	`long x = v; // cast narrow int v to long, otherwise v left shift will fail when n > 15.`
	`//perform mask operation with long 3L not int 3	`
	`cubes[n / 32] &= ~(3L << (n % 32) * 2);`
	`cubes[n / 32] |= x << (n % 32) * 2;`
`}`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant