Declaring Int256?

Julia’s documentation describes how primitive integers are declared here:
https://docs.julialang.org/en/v1/manual/types/#Primitive-Types-1

I want to use an Int256, but this throws an error:

primitive type Int256  <: Signed   256 end
primitive type UInt256  <: Unsigned   256 end
arr = Array{Int128}(undef, 5)

I get a pop up saying:

flipsign not defined for Int256

error(::String, ::String, ::Type) at error.jl:42

no_op_err(::String, ::Type) at promotion.jl:388

flipsign(::Int256, ::Int256) at promotion.jl:418

abs(::Int256) at int.jl:136

split_sign(::Int256) at intfuncs.jl:620

#string#323(::Int64, ::Int64, ::typeof(string), ::Int256) at intfuncs.jl:645

string(::Int256) at intfuncs.jl:638

show(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Int256) at show.jl:589

#sprint#342(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Int64, ::typeof(sprint), ::Function, ::Int256) at io.jl:105

(::getfield(Base, Symbol("#kw##sprint")))(::NamedTuple{(:context, :sizehint),Tuple{IOContext{Base.GenericIOBuffer{Array{UInt8,1}}},Int64}}, ::typeof(sprint), ::Function, ::Int256) at none:0

alignment(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Int256) at show.jl:1791

alignment(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Array{Int256,1}, ::UnitRange{Int64}, ::UnitRange{Int64}, ::Int64, ::Int64, ::Int64) at arrayshow.jl:68

print_matrix(::IOContext{Base.GenericIOBuffer{Array{UInt8,1}}}, ::Array{Int256,1}, ::String, ::String, ::String, ::String, ::String, ::String, ::Int64, ::Int64) at arrayshow.jl:186

Why doesn’t this work?

You have only defined the type, but then you define all the methods that may be needed. Note in particular that the error comes from trying to print the numbers, if you put a semicolon at the end of the line in the REPL

arr = Array{Int256}(undef, 5);

you don’t get any error.

5 Likes