mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-22 21:52:31 +03:00
Add note about integer overflow
Something that may trip users coming from a Python background as per https://discourse.julialang.org/t/julia-messes-up-integer-exponents/20773
This commit is contained in:
parent
1980272c4f
commit
18c010ecd9
@ -46,6 +46,13 @@ div(5, 2) # => 2 # for a truncated result, use div
|
|||||||
# Enforce precedence with parentheses
|
# Enforce precedence with parentheses
|
||||||
(1 + 3) * 2 # => 8
|
(1 + 3) * 2 # => 8
|
||||||
|
|
||||||
|
# Julia (unlike Python for instance) has integer under/overflow
|
||||||
|
10^19 # => -8446744073709551616
|
||||||
|
# use bigint or floating point to avoid this
|
||||||
|
big(10)^19 # => 10000000000000000000
|
||||||
|
1e19 # => 1.0e19
|
||||||
|
10.0^19 # => 1.0e19
|
||||||
|
|
||||||
# Bitwise Operators
|
# Bitwise Operators
|
||||||
~2 # => -3 # bitwise not
|
~2 # => -3 # bitwise not
|
||||||
3 & 5 # => 1 # bitwise and
|
3 & 5 # => 1 # bitwise and
|
||||||
|
Loading…
Reference in New Issue
Block a user