Home » Julia

Finding the maximum/largest value of a data type in Julia

Julia typemax() function example: Here, we are going to learn how to find the maximum/largest value of a data type in Julia programming language?
Submitted by IncludeHelp, on March 27, 2020

To find the maximum value that a data type can hold, we use the typemax() function – it accepts a data type and returns its maximum value.

Example:

# finding the maximum values of the various
# data types

print("Max value of Int8: ")
println(typemax(Int8))

print("Max value of UInt8: ")
println(typemax(UInt8))

print("Max value of Int16: ")
println(typemax(Int16))

print("Max value of UInt16: ")
println(typemax(UInt16))

print("Max value of Int32: ")
println(typemax(Int32))

print("Max value of UInt32: ")
println(typemax(UInt32))

print("Max value of Int64: ")
println(typemax(Int64))

print("Max value of UInt64: ")
println(typemax(UInt64))

print("Max value of Int128: ")
println(typemax(Int128))

print("Max value of UInt128: ")
println(typemax(UInt128))

print("Max value of Bool: ")
println(typemax(Bool))

Output

Max value of Int8: 127
Max value of UInt8: 255
Max value of Int16: 32767
Max value of UInt16: 65535
Max value of Int32: 2147483647
Max value of UInt32: 4294967295
Max value of Int64: 9223372036854775807
Max value of UInt64: 18446744073709551615
Max value of Int128: 170141183460469231731687303715884105727
Max value of UInt128: 340282366920938463463374607431768211455
Max value of Bool: true


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.