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

Behavior of floor, ceil is surprising #78

Closed
ajkeller34 opened this issue Apr 23, 2017 · 2 comments
Closed

Behavior of floor, ceil is surprising #78

ajkeller34 opened this issue Apr 23, 2017 · 2 comments

Comments

@ajkeller34
Copy link
Collaborator

floor and ceil pretend the units aren't there. Not sure why I did it this way, but I think this warrants reconsideration:

julia> 20u"µm"/(110u"nm")
0.18181818181818182 nm^-1 μm

julia> floor(ans)
0.0 nm^-1 µm

julia> Int(ans)
0

... which is different from the expected answer of 181. My inclination is to define floor and ceil only for dimensionless quantities and have them convert to a unitless number first.

@giordano
Copy link
Collaborator

Also isinteger really depends on the actual units and can give unexpected result for non simplified quantities:

julia> isinteger(1u"m" / 10u"mm")
false

julia> isinteger(uconvert(NoUnits, 1u"m" / 10u"mm"))
true

ajkeller34 added a commit that referenced this issue May 11, 2017
@ajkeller34
Copy link
Collaborator Author

trunc and round also had the same problems, but I think the latest patch should fix these issues.

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