Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Julia> (1,2,3) return (1,2,0)

Tags:

julia

I've been working through the Julia Tutorial, and strangely (1,2,3) returns (1,2,0).

(1,2,3,4) returns (1,2,0,0)

(1,2,3,4,5) returns (1,2,3,4,5) as expected.

It seems that sets of size 3 or 4 replace the 3rd and fourth elements with 0. I don't expect that this is normal behavior but I'm not familiar with the environment so I'm not sure with what I might have done to cause this.

I deleted all julia files from my profile and restarted the interpreter, and the behavior persists.

Version 0.3.5 (2015-01-08 22:33 UTC) under windows executed in cygwin. Same problem when executed from command.

like image 430
gbegley Avatar asked Feb 10 '15 03:02

gbegley


People also ask

Why do Julia arrays start at 1?

Arrays in the Julia programming language are somewhat different from arrays in other programming languages. Not because of different behavior, but because they are start at 1 instead of 0. It's because Julia is used for mathematics , machine learning and scientific etc.

Is Julia 1 or 0 indexed?

Conventionally, Julia's arrays are indexed starting at 1, whereas some other languages start numbering at 0, and yet others (e.g., Fortran) allow you to specify arbitrary starting indices.

Why does Julia use end?

(11:13, 1:3) . Julia uses end to denote the end of conditional blocks, like if , loop blocks, like while / for , and functions. In lieu of the one-line if ( cond ) statement , Julia allows statements of the form if cond; statement; end , cond && statement and ! cond || statement .

What does Float64 mean in Julia?

By definition, eps(1.0) is the same as eps(Float64) since 1.0 is a 64-bit floating-point value.


1 Answers

This is a (very strange!) long standing display bug on Windows. You can read about it at the link - in short, the value is correct but it doesn't display right. It should also be fixed in final release of Julia 0.4, which will use LLVM 3.5 (at least, thats what the thread says).

like image 91
IainDunning Avatar answered Oct 10 '22 13:10

IainDunning