# Endian of reinterpret(T, array)

**URL:** https://discourse.julialang.org/t/endian-of-reinterpret-t-array/5272
**Category:** General Usage
**Created:** [August 8, 2017, 3:41am UTC](https://discourse.julialang.org/t/endian-of-reinterpret-t-array/5272 "2017-08-08T03:41:14Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sambitdash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sambitdash/32/1377_2.png) [@sambitdash](https://discourse.julialang.org/u/sambitdash)
#### Post date: [August 8, 2017, 3:41am UTC](https://discourse.julialang.org/t/endian-of-reinterpret-t-array/5272/1 "2017-08-08T03:41:14Z")

</div>

Hi All,

I was received an array from a file as:

```julia
julia> a1 = UInt8[0x0, 0x32, 0, 0x33, 0, 0x34, 0, 0x35,0,0]
10-element Array{UInt8,1}:
 0x00
 0x32
 0x00
 0x33
 0x00
 0x34
 0x00
 0x35
 0x00
 0x00

julia> a2 = reinterpret(UInt16, a1) # See the order flip here of the bytes
5-element Array{UInt16,1}:
 0x3200
 0x3300
 0x3400
 0x3500
 0x0000

julia> transcode(String, a2)
"㈀㌀㐀㔀\0"

```

Is Julia little endian by default or the behavior will depend on the processor type?

regards,

Sambit

---

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [August 8, 2017, 4:05am UTC](https://discourse.julialang.org/t/endian-of-reinterpret-t-array/5272/2 "2017-08-08T04:05:10Z")

</div>

`reinterpret` is direct memory cast so it’s always native endian (and in practice always little endian)…

---

<div class="post-metadata">

### Author: ![sambitdash](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sambitdash/32/1377_2.png) [@sambitdash](https://discourse.julialang.org/u/sambitdash)
#### Post date: [August 8, 2017, 4:07am UTC](https://discourse.julialang.org/t/endian-of-reinterpret-t-array/5272/3 "2017-08-08T04:07:55Z")

</div>

Thanks @yuyichao

I think I got what I wanted. I will need to write the code by first querying `Base.ENDIAN_BOM` and then see if nto\* methods can be used.
