[rust-dev] Why are generic integers not usable as floats?

Benjamin Striegel ben.striegel at gmail.com
Thu Jun 19 16:23:40 PDT 2014


I'm actually very pleased that floating point literals are entirely
separate from integer literals, but I can't quite explain why. A matter of
taste, I suppose. Perhaps it stems from symmetry with the fact that I
wouldn't want `let x: int = 1.0;` to be valid.


On Thu, Jun 19, 2014 at 7:02 PM, Matthew McPherrin <matt at 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 at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140619/07ff44d4/attachment.html>


More information about the Rust-dev mailing list