DEV Community

Cover image for Learning Julia(1): basics
Z. QIU
Z. QIU

Posted on • Edited on

1

Learning Julia(1): basics

Alt Text

Alt Text

#     one '#' symbole for a one-line comment, equal to // in C/C++

#=    '#=' + '=#' pair for multi-line comment
      similar to '/*'+'*/' pair in C/C++
=#

## as in java, println(xxx) is equivalent to print(xxx + '\n')


########   day 1:   Numbers
a = 1
println("a: ", a, ",", typeof(a))   ## Int64 if running on 64-bit CPU, Int32 for 32-bit CPU

aa = UInt8(1)     # method to convert to a specific type
println(a == aa)
println(sizeof(a), ", " ,sizeof(aa))

b = 3.2
println("b: ", b, ",", typeof(b))
println(sizeof(b))

c = 1e18
println("c: ", c, ",", typeof(c))

d = 0x3f
println("d: ", d, ",", typeof(d))

e = 0b10 
println("e: ", e, ",", typeof(e))

f = 0o057
println("f: ", f, ",", typeof(f))


g = 'x'
println("g: ", g, ",", typeof(g))
println("g-1: ", g-1, ",", typeof(g-1))
println(g == UInt8('x'))
g= convert( UInt8, g)  # convert function for converting types
println(g == UInt8('x'))

h = 2 + 3im
println("h: ", h, ", ", typeof(h))


i = 0.5f
println("i: ", i, ", ", typeof(i))

j = Inf - Inf
println("j: ", j, ", ", typeof(j))

k = Inf * 0
println("k: ", k, ", ", typeof(k))

l = 2/0
println("l: ", l, ", ", typeof(l))


m = 6//9

println("m: ", m, ", ", typeof(m))

n = bitstring(65535)
println("n: ", n, ", ", typeof(n))

Enter fullscreen mode Exit fullscreen mode

Below is the output that I got:
Alt Text

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay