Julia: Simple multiplication paradox e.g 1141241515151*124124124124124

Created on 13 Aug 2018  路  3Comments  路  Source: JuliaLang/julia

Perhaps there are some bugs in the high precision computation or misuse of data types.
My platform is MacOS High Sierra 10.13.2.
2018-08-13 9 43 26

  • The upper one is computed by matlab and the under is by Julia.

Most helpful comment

Note that in Matlab 1141241515151 and 124124124124124 are floating-point values, not integers, which lose precision instead of overflowing. You can get the Matlab-like behavior this way:

julia> 1141241515151.0*124124124124124.0
1.4165560348220606e26

All 3 comments

This is an integer overflow, which is intentional (docs).

Note that you can get the correct answer as follows:

julia> BigInt(1141241515151)*BigInt(124124124124124) 
141655603482206064550602724

Note that in Matlab 1141241515151 and 124124124124124 are floating-point values, not integers, which lose precision instead of overflowing. You can get the Matlab-like behavior this way:

julia> 1141241515151.0*124124124124124.0
1.4165560348220606e26

That's really a cool design! Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

i-apellaniz picture i-apellaniz  路  3Comments

omus picture omus  路  3Comments

manor picture manor  路  3Comments

TotalVerb picture TotalVerb  路  3Comments

musm picture musm  路  3Comments