If either f or g is in a base ring of the other, then that one is promoted so that both are elements in the same ring R.
The fraction will be an element of the fraction field, frac R, of R. If R is already a field, then this means that the fraction will be an element of R.
i2 : R = GF(9,Variable=>a);

i3 : (a/a^3) * a^2 == 1
o3 = true

i4 : S = ZZ[a,b]
o4 = S
o4 : PolynomialRing

i5 : (a^6b^6)/(a^9b^9)
3 3
a + b
o5 = 
6 3 3 6
a + a b + b
o5 : frac S

If the ring contains zero divisors, the fraction field is not defined. Macaulay2 will not inform you of this right away. However, if computation finds a zerodivisor, an error message is generated.
i6 : A = ZZ/101[a,b]/(a*b)
o6 = A
o6 : QuotientRing

i7 : (a+b)/(ab)
b
o7 = 
b
o7 : frac A

At this point, if one types
a/b, then Macaulay2 would give an error saying that a zero divisor was found in the denominator.