-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
Improve documentation of int #70046
Improve documentation of int #70046
Conversation
bcf76e2
to
215bb18
Compare
b17b4df
to
d3b2b8b
Compare
d3b2b8b
to
7c98b5a
Compare
max_int += 1 | ||
print(max_int) # -9223372036854775808, we overflowed and wrapped around. | ||
var x: int = 1 # x is 1 | ||
x = 4.2 # x is 4, because 4.2 gets truncated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you removed the mention of type hints from the above text, we should probably mention it in the code sample. Particularly since var x = 1
would also work and be an integer, the difference is that it would change the behavior of x = 4.2
, with the hint it's casted to 4, without it stores the float 4.2. We want to inform users that : int
is not a required part of using the integer type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I don't know how to do this gracefully. While we wouldn't want to explain how static typing works here, we do want to explain the whole back-and-forth between int
and float
(for example how passing an int
to a function that accepts a float
will just do an appropriate conversion). Maybe I could explain that this also holds for statically-typed vars as an example?
7c98b5a
to
10c8eed
Compare
10c8eed
to
d09dde0
Compare
d09dde0
to
391d910
Compare
391d910
to
0f31975
Compare
This is great, thanks! |
Cherry-picked for 4.0.2. |
Main description:
_
and binary/hex literals0b
and0x
.The rest of the page:
0b
to explain bitwise operators.Changed how operator descriptions are worded:
int + float
-> "the int", "the float"int + int
-> "the two ints" / "the left int", "the right int"