From 18c010ecd9b654be5bf6d4dfcd68aeb41edfc3a1 Mon Sep 17 00:00:00 2001 From: Thibaut Lienart Date: Mon, 18 Feb 2019 12:25:23 +1100 Subject: 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 --- julia.html.markdown | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'julia.html.markdown') diff --git a/julia.html.markdown b/julia.html.markdown index eabb988e..5e9ef1b8 100644 --- a/julia.html.markdown +++ b/julia.html.markdown @@ -46,6 +46,13 @@ div(5, 2) # => 2 # for a truncated result, use div # Enforce precedence with parentheses (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 ~2 # => -3 # bitwise not 3 & 5 # => 1 # bitwise and -- cgit v1.2.3