Rust is obviously a new language (0.8). It looks interesting, and I'm starting to look at it. I came across a mention of some software where float
was changed to f64
, so I wanted to find where the data-types, including float
were defined. I couldn't find anything very specific. I did find:
There are three floating-point types:
float
,f32
, andf64
. Floating-point numbers are written0.0
,1e6
, or2.1e-4
. Like integers, floating-point literals are inferred to the correct type. Suffixesf
,f32
, andf64
.
I guess "float" or "f" is 16 bit.
On a more general note (I'm no computer scientist), is it really worth messing around with all these small data-types like int
, int32
, int64
, f
, f32
, f64
(to name a few). I can understand some languages having eg. a byte-type, because string is a fairly complex type. For numeric-types, I think it just creates unnecessary complexity. Why not just have i64
and f64
and call them int and float (or i64
and f64
to cater for future changes, or have float and int default to these).
Perhaps there are some low-level programs that require smaller values, but why not reserve the usage to those programs that need them and leave them out of the core? I find it an unnecessary chore to convert from eg. int
to i64
, etc., and what does it really achieve? Alternatively, leave them in the "core", but default to the 64-bit types. The 64-bit types are obviously necessary, whereas the rest are only necessary for specific cases (IMO).