fn main() { println!("{}", 16777217f32) }

This program prints 16777216.  So I think allowing integer literals doesn't
really change anything, since you can already type unrepresentable float
literals.  That said, this ought to at least trigger a warning like
type_overflow does for integers.



On Thu, Jun 19, 2014 at 4:06 PM, Cameron Zwarich <zwar...@mozilla.com>
wrote:

> Not all integer constants can be perfectly represented as floating-point
> values. What do you propose in that case, just a hard error?
>
> Cameron
>
> On Jun 19, 2014, at 4:02 PM, Matthew McPherrin <m...@mcpherrin.ca> wrote:
>
> This came up on IRC today, and it was something I've wondered in the past
> but nobody had an immediately good answer either way.
>
> I think it's fairly inconsistent that these two code samples aren't
> equivalent:
>
>     let a = 1f32;
>   let b: f32 = 1;
>
> It's fairly annoying in my opinion to have to occasionally add a .0 after
> floating point literals.
>
> Especially since we're getting rid of integer fallback in RFC 30, I think
> this issue ought to be thought about.
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to