We can get the numerator of a float value by using the numerator
method.
float_value.numerator
float_value
: This is the float value we want to get the numerator of.
The value returned is an integer that represents the numerator of the float value, float_value
.
Note: The numerator returned is machine dependent.
# create float valuesf1 = 2.0f2 = 5 / 2f3 = 0.666f4 = 100.77# get numeratorputs f1.numeratorputs f2.numeratorputs f3.numeratorputs f4.numerator
numerator
method on the float values we created. We then print the results to the console.