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

floor() and ceiling() could use 10ths, 100ths, etc like round() has. #2556

Closed
Dunbaratu opened this issue Jul 1, 2019 · 2 comments · Fixed by #2629
Closed

floor() and ceiling() could use 10ths, 100ths, etc like round() has. #2556

Dunbaratu opened this issue Jul 1, 2019 · 2 comments · Fixed by #2629
Labels
enhancement Something new (not a bug fix) is being requested

Comments

@Dunbaratu
Copy link
Member

Dunbaratu commented Jul 1, 2019

With round() you can pick the number of digits after the decimal to round to, i.e. round(x, 2) to round to the nearest hundredth.

But floor() and ceiling() only work for going to an integer, not tenths or hundredths, etc.

They could use a similar optional second parameter like Round() has, that does the same thing.

i.e. while round(1.666, 2) would give 1.67, floor(1.666, 2) would give 1.66.

Without that, people have to resort to the workaround of multiplying by a power of ten to shift the decimal point, then calling floor() then shifting it back, like so:
to get the effect of floor(x, 2) the script has to do: floor(x*100) / 100.

@Dunbaratu Dunbaratu added the enhancement Something new (not a bug fix) is being requested label Jul 1, 2019
@teleksterling
Copy link

Consider whether it should also handle negative values too round to 10, 100 with input -1, -2 respectively.

@ThunderousEcho
Copy link
Contributor

Added the second parameter to these functions on my branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something new (not a bug fix) is being requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants