-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
docs: fix errors in docs #7801
docs: fix errors in docs #7801
Conversation
fn main() {
a := int(12)
mut f := f32(0)
f = a
println(f)
} this compiles cleanly and prints: |
It's not a question of whether or not some ints can be cast to f32, it is whether or not all ints can be cast to f32. They can't, because f32 only handles up to 7 digit integers, where an int can be up to 10 digits. If you try to store all ints in an f32, you lose precision as the number gets higher. |
We could either remove the arrow or mention that not all ints can be converted to f32. But the latter might confuse users so we would have to include an example of what can and cannot be converted successfully. However, to keep things simple it might be better to just remove the arrow. |
That's right and that is why in #4971 and #5155 I had originally added checks that did forbid The philosophy now is somehow: Conversion is allowed if the result fits in the limits of the target type, but we may lose (some) precision. |
It's possible to convert It might be a good idea to define what the arrow and it's direction means, for types
From your point @UweKrueger,
I gather it to be 2 and 3. So either we should add bidirectional arrows However, if 1 and 2 are the correct ones, then we should remove the arrow. |
I myself still can't make the decision. I incline to believe @dumblob is right and that commit that I asked you to push @UweKrueger has to be reverted. But I still need to think about it and do research. |
The question is always what the default behavior should be. It might be less difficult to decide if we introduced some new arguments like So, as you already noticed, I always prefer correct and well defined behavior on all supported platforms by default. |
In all cases, the documentation should match the code, otherwise it is misleading to the reader. |
@spytheman Alright, I've kept the arrows intact. |
Hello V community,
I've made two changes:
int
tof32
because as the documentation says that conversion cannot be made (unless I have misunderstood it):Cheers!