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

Support Units in Ceil and Floor #3216

Open
tholum opened this issue Jun 3, 2024 · 4 comments
Open

Support Units in Ceil and Floor #3216

tholum opened this issue Jun 3, 2024 · 4 comments

Comments

@tholum
Copy link

tholum commented Jun 3, 2024

The issues section is used only for bug reports. Please use the Discussions section to ask questions and share ideas and suggestions.

Describe the bug
This is a feature request more of a bug, Seeing there are test's in place verify it is not supported, but I would like to be able to use ceil and floor on numbers with units,

For example evaluate('ceil( 10.42ft / 2 )')

To Reproduce
evaluate('ceil( 10.42ft / 2 )')

@josdejong
Copy link
Owner

Thanks for your feature request. We can indeed extend ceil, floor, and fix to support units, similar to round: #3095.

Anyone interested in implementing this?

@yaojiejia
Copy link

Hello! How complex should this unit's evaluation be? For example, do we need to consider cases like evaluate('ceil( 10.42ft / 2m )') and will ceil to a selected unit? Or just a unified unit across the function.

@josdejong
Copy link
Owner

I think your example 10.42ft / 2m results in number, which is already supported by ceil, so I think that doesn't make a difference.

The core here is to extend the functions ceil, floor, and fix with new signatures so they support:

ceil(x)
ceil(x, n)
ceil(unit, valuelessUnit)     # to be implemented
ceil(unit, n, valuelessUnit)  # to be implemented

floor(x)
floor(x, n)
floor(unit, valuelessUnit)    # to be implemented
floor(unit, n, valuelessUnit) # to be implemented

fix(x)
fix(x, n)
fix(unit, valuelessUnit)      # to be implemented
fix(unit, n, valuelessUnit)   # to be implemented

@orelbn
Copy link
Contributor

orelbn commented Sep 22, 2024

I think your example 10.42ft / 2m results in number, which is already supported by ceil, so I think that doesn't make a difference.

The core here is to extend the functions ceil, floor, and fix with new signatures so they support:

ceil(x)
ceil(x, n)
ceil(unit, valuelessUnit)     # to be implemented
ceil(unit, n, valuelessUnit)  # to be implemented

floor(x)
floor(x, n)
floor(unit, valuelessUnit)    # to be implemented
floor(unit, n, valuelessUnit) # to be implemented

fix(x)
fix(x, n)
fix(unit, valuelessUnit)      # to be implemented
fix(unit, n, valuelessUnit)   # to be implemented

Hi Jos,

I gave it a try. Please take a look when you have a chance.

Thanks!

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

No branches or pull requests

4 participants