julia提取第一列
Julia| 文字零和一 (Julia | Literal zero and one)
In Julia, if we need to find the literal 0 and 1 corresponding to a specific data type we need to use zero() and one() functions. Julia provides these two library functions for this purpose.
在Julia中,如果需要找到与特定数据类型相对应的文字0和1,则需要使用zero()和one()函数。 为此,Julia提供了这两个库函数。
zero() and one() functions accept a type/value and returns the literal 0 and 1 corresponding to a specific data type, type of the given value/variable.
zero()和one()函数接受类型/值,并返回与特定数据类型(给定值/变量的类型)相对应的文字0和1。
Syntax:
句法:
zero(x)
one(x)
Here, x is the data type or value or variable.
在此, x是数据类型或值或变量。
Example 1: Finding literal 0 and 1 of given data type
示例1:查找给定数据类型的文字0和1
# Julia example of
# zero() and one() functions
println("zero(Int64): ", zero(Int64))
println("zero(Float32): ", zero(Float32))
println("zero(Float64): ", zero(Float64))
println("zero(Bool): ", zero(Bool))
println("one(Int64): ", one(Int64))
println("one(Float32): ", one(Float32))
println("one(Float64): ", one(Float64))
println("one(Bool): ", one(Bool))
Output
输出量
zero(Int64): 0
zero(Float32): 0.0
zero(Float64): 0.0
zero(Bool): false
one(Int64): 1
one(Float32): 1.0
one(Float64): 1.0
one(Bool): true
Example 2: Finding literal 0 and 1 of given value type
示例2:查找给定值类型的文字0和1
# Julia example of
# zero() and one() functions
println("zero(10): ", zero(10))
println("zero(10.23): ", zero(10.23))
println("zero(true): ", zero(true))
println("zero(-10): ", zero(-10))
println("zero(-10.23): ", zero(-10.23))
println("one(10): ", one(10))
println("one(10.23): ", one(10.23))
println("one(true): ", one(true))
println("one(-10): ", one(-10))
println("one(-10.23): ", one(-10.23))
Output
输出量
zero(10): 0
zero(10.23): 0.0
zero(true): false
zero(-10): 0
zero(-10.23): 0.0
one(10): 1
one(10.23): 1.0
one(true): true
one(-10): 1
one(-10.23): 1.0
Example 3: Finding literal 0 and 1 of given variable type
示例3:查找给定变量类型的文字0和1
# Julia example of
# zero() and one() functions
a = 10
b = 10.23
c = true
d = -10
e = -10.23
println("zero(a): ", zero(a))
println("zero(b): ", zero(b))
println("zero(c): ", zero(c))
println("zero(d): ", zero(d))
println("zero(e): ", zero(e))
println("one(a): ", one(a))
println("one(b): ", one(b))
println("one(c): ", one(c))
println("one(d): ", one(d))
println("one(e): ", one(e))
Output
输出量
zero(a): 0
zero(b): 0.0
zero(c): false
zero(d): 0
zero(e): 0.0
one(a): 1
one(b): 1.0
one(c): true
one(d): 1
one(e): 1.0
Reference: Integers and Floating-Point Numbers
参考: 整数和浮点数
翻译自: https://www.includehelp.com/julia/literal-zero-and-one.aspx
julia提取第一列