mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
doc: reflect current int → f32 behaviour (#9433)
This commit is contained in:
@@ -434,9 +434,10 @@ These are the allowed possibilities:
|
|||||||
i8 → i16 → int → i64 ⬏
|
i8 → i16 → int → i64 ⬏
|
||||||
```
|
```
|
||||||
An `int` value for example can be automatically promoted to `f64`
|
An `int` value for example can be automatically promoted to `f64`
|
||||||
or `i64` but not to `f32` or `u32`. (`f32` would mean precision
|
or `i64` but not to `u32`. (`u32` would mean loss of the sign for
|
||||||
loss for large values and `u32` would mean loss of the sign for
|
|
||||||
negative values).
|
negative values).
|
||||||
|
Promotion from `int` to `f32`, however, is currently done automatically
|
||||||
|
(but can lead to precision loss for large values).
|
||||||
|
|
||||||
Literals like `123` or `4.56` are treated in a special way. They do
|
Literals like `123` or `4.56` are treated in a special way. They do
|
||||||
not lead to type promotions, however they default to `int` and `f64`
|
not lead to type promotions, however they default to `int` and `f64`
|
||||||
|
|||||||
Reference in New Issue
Block a user