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

alias "int" is misleading #86

Open
Butterroach opened this issue Aug 30, 2024 · 1 comment
Open

alias "int" is misleading #86

Butterroach opened this issue Aug 30, 2024 · 1 comment

Comments

@Butterroach
Copy link

the issue is at line 224 of scripts/audioProcessor.mjs

		params.push('int', 'window');
		values.push(Math.floor, globalThis);

when a function is called int it usually means the function truncates the value passed, here it's actually flooring the value

the difference between flooring and truncating is that flooring will round towards -infinity, while truncating will round towards 0

for example, -2.4 will be floored to -3, but it will be truncated to -2

you can change the int to be an alias to Math.trunc to fix this

@SthephanShinkufag
Copy link
Owner

SthephanShinkufag commented Aug 30, 2024

Replacing floor with int was originally taken from the Greggman player:
https://github.com/greggman/html5bytebeat/blob/master/src/ByteBeatCompiler.js#L339
I can fix it, but I'll have to look through all the library, I once replaced floor with int everywhere in the minimized and formatted versions.

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

No branches or pull requests

2 participants