Express D.toFixed( 1 )
as a fraction.
D
The number T
is in the tenths place, so we have cardinal( T ) tenths.
Cardinal( T ) tenths can be written as fraction( T, 10 )
.
Express D.toFixed( 2 )
as a fraction.
D
The number T
is in the tenths place, so we have cardinal( T ) tenths.
Cardinal( T ) tenths can be written as fraction( T, 10 )
.
The number H
is in the hundredths place, so we have cardinal( H ) hundredths.
Cardinal( H ) hundredths can be written as fraction( H, 100 )
.
Add the two parts together.
fraction( T, 10 ) + fraction( H, 100 )
= fraction( T * 10, 100 ) + fraction( H, 100 )
= fraction( T * 10 + H, 100 )
You can also skip a few steps by making a fraction with floor( D * 100 )
as the numerator and 100
(because the decimal extends to the hundredths place) as the denominator.
fraction( T * 10 + H, 100 )