julia> 2^3^4
0
julia>
Julia
- Polter
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Julia
Associativity agrees with GP/PARI and R.
Error reporting -- um, yeah...
GP/PARI
gp > 2^3^4
%1 = 2417851639229258349412352
gp > 2.^3.^4.
%2 = 2417851639229258349412352.007
MATLAB
>> 2^3^4
ans = 4096
>> 2.^3.^4.
ans = 4096
>> (2.^3).^4.
ans = 4096
>> 2.^(3.^4.)
ans = 2.4179e+024
R
> 2^3^4
[1] 2.417852e+24
> 2.^3.^4.
[1] 2.417852e+24
Julia
julia> 2^3^4
0
julia> typeof(2^3^4)
Int32
julia> uint64(2)^uint64(3)^uint64(4)
0x0000000000000000
julia> typeof(uint64(2)^uint64(3)^uint64(4))
Uint64
julia> 2.^3.^4.
2.4178516392292583e24
julia> typeof(2.^3.^4.)
Float64
Error reporting -- um, yeah...
GP/PARI
gp > 2^3^4
%1 = 2417851639229258349412352
gp > 2.^3.^4.
%2 = 2417851639229258349412352.007
MATLAB
>> 2^3^4
ans = 4096
>> 2.^3.^4.
ans = 4096
>> (2.^3).^4.
ans = 4096
>> 2.^(3.^4.)
ans = 2.4179e+024
R
> 2^3^4
[1] 2.417852e+24
> 2.^3.^4.
[1] 2.417852e+24
Julia
julia> 2^3^4
0
julia> typeof(2^3^4)
Int32
julia> uint64(2)^uint64(3)^uint64(4)
0x0000000000000000
julia> typeof(uint64(2)^uint64(3)^uint64(4))
Uint64
julia> 2.^3.^4.
2.4178516392292583e24
julia> typeof(2.^3.^4.)
Float64
MadMax, some curiosities regarding the performance of std::accumulate are also related to it using operator+ (not operator+=) and issues with trying to optimize it with move semantics (from a compiler point of view) keeping standard-compliance; discussion here: http://gcc.gnu.org/ml/libstdc++/2011-01/msg00015.html
I solely mention those as "curiosities", since I wouldn't expect them to have an impact on "small" data structures (like a built-in double) (and the example above considers std::string), but it might still be of interest.
I solely mention those as "curiosities", since I wouldn't expect them to have an impact on "small" data structures (like a built-in double) (and the example above considers std::string), but it might still be of interest.
- jslade
- Posts: 0
- Joined: Thu Jan 01, 2004 12:00 am
Julia
Is 32bit overflow a big deal? Pretty much every high performance language (OCaML, *cough* Java, C, whatever) that isn't a Lisp does this. R doesn't exactly handle it gracefully either.
I'd be more concerned with stack overflows.
I'd be more concerned with stack overflows.
"Alles hat ein ende, nun die wurst hat zwei."