Home »
Julia
numerator() function in Julia
Julia | numerator() function: In this tutorial, we are going to learn about the numerator() function with example in Julia programming language.
Submitted by IncludeHelp, on March 30, 2020
Julia | numerator() function
numerator() function is a library function in Julia programming language, it is used to get the numerator of the rational representation of the given value.
Syntax:
numerator(x)
Here, x is the rational representation.
Example:
numerator(1//2)
1
numerator(2//3)
2
numerator(2//4)
1
Program:
# Example of numerator() function in Julia
x = 1//2
y = 2//3
z = 2//4
println("numerator(x): ", numerator(x))
println("numerator(y): ", numerator(y))
println("numerator(z): ", numerator(z))
println()
a = 2
b = 3
c = 4
println("numerator(a): ", numerator(a))
println("numerator(b): ", numerator(b))
println("numerator(c): ", numerator(c))
println()
Output
numerator(x): 1
numerator(y): 2
numerator(z): 1
numerator(a): 2
numerator(b): 3
numerator(c): 4
Reference: Julia Base.numerator()