Wednesday, 13 April 2016

Julia: bitstype: declare new concrete type


By using bitstype, you can define a concrete type with given number of bits in size.

Synatx
bitstype noOfBits newType
bitstype noOfBits  newType <: parentType

noOfBits: Number of bits of storage for given type. It should be multiple of 8.
newType: Name of the type
parentType: Specifies the parent type of given type

julia> bitstype 8 noOfDays  <: Integer

julia> show(x::noOfDays) = print("noOfDays($(reinterpret(Int32,x)))")
show (generic function with 1 method)

julia> reinterpret(noOfDays, Int8(123))
noOfDays(0x7b)




Previous                                                 Next                                                 Home

No comments:

Post a Comment