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

high(float) & low(float) #5039

Closed
define-private-public opened this issue Nov 20, 2016 · 15 comments
Closed

high(float) & low(float) #5039

define-private-public opened this issue Nov 20, 2016 · 15 comments
Labels

Comments

@define-private-public
Copy link
Contributor

There exists high(int) and low(int), but when I tried to do high(float), the compiler gave me an Error: invalid argument for 'high'

Is it possible to add high() and low() procs for the float type?

@Araq
Copy link
Member

Araq commented Nov 20, 2016

What that be? Floats support +-INF. When is this useful?

@define-private-public
Copy link
Contributor Author

Sorry, didn't know about that. I was using it along with this random proc: http://nim-lang.org/docs/random.html#random,float

@dom96
Copy link
Contributor

dom96 commented Sep 27, 2017

Wouldn't it make sense for high(float) to return INF?

@dom96 dom96 reopened this Sep 27, 2017
@Araq
Copy link
Member

Araq commented Sep 27, 2017

And what would that accomplish? Which use cases does this cover? Why did we get away without for years?

@dom96
Copy link
Contributor

dom96 commented Sep 27, 2017

It would save me time googling why high(float) doesn't work.

@define-private-public
Copy link
Contributor Author

I think that might be an okay idea. It's logical if people think there is a high(int), high(short), high(char), they might assume that there is a high(float), even though floating point numbers are radically different. It would stop people from having to learn another "gotcha," for this language.

@Araq
Copy link
Member

Araq commented Sep 28, 2017

It would save me time googling why high(float) doesn't work.

You can save my time now and tell me why you wrote high(float) in the first place.

@Araq
Copy link
Member

Araq commented Sep 28, 2017

It would stop people from having to learn another "gotcha," for this language.

"My non-sensical expression didn't compile" is NOT a gotcha.

@tmerr
Copy link

tmerr commented Sep 28, 2017

Interesting... Rust's f32::MAX gives the highest finite value https://doc.rust-lang.org/stable/std/f32/

@Yardanico
Copy link
Collaborator

@tmerr why it can be useful though?

@tmerr
Copy link

tmerr commented Sep 28, 2017

@Yardanico no idea. It seems like c++'s float max does the same thing: http://www.cplusplus.com/reference/limits/numeric_limits/ . It would be good to understand the motivation for this before making a decision in nim

@yglukhov
Copy link
Member

It might be useful for generic code, imo.

@johnnovak
Copy link
Contributor

The only thing that would make sense to me is to return the highest/lowest safely representable value. But i'm finding hard to find a real-world use-case for this... The numerical limit constants are probably enough for all practical purposes.

@skilchen
Copy link
Contributor

Just for fun, i was playing around with floats. If somebody is interested in some of the special floats, please take a look at: https://play.nim-lang.org/?gist=6dca0bb2f6b2fb99fa4fbb9e8af3d74a

@bluenote10
Copy link
Contributor

Can be closed now that #6570 is merged.

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

No branches or pull requests

10 participants