i'm writing a fraction calculator for part of an assignment....
anyways, i have to use bytes, like the numerator is a byte and the denominator is a byte, i have a constructor setup to take two bytes in to make a new Fraction object....in my add method when i compute the result and try to call the constructor it wont work because once i multiply numerators and denominators of bytes together, it's put into int form and therefore cant get to the constructor, is there any way i can convert that int result into a byte so i can send it back...
i've tried using the byteValue() method but it says it cannot be applied to the primitive int type, how can i fix it?
Question
lime
i'm writing a fraction calculator for part of an assignment....
anyways, i have to use bytes, like the numerator is a byte and the denominator is a byte, i have a constructor setup to take two bytes in to make a new Fraction object....in my add method when i compute the result and try to call the constructor it wont work because once i multiply numerators and denominators of bytes together, it's put into int form and therefore cant get to the constructor, is there any way i can convert that int result into a byte so i can send it back...
i've tried using the byteValue() method but it says it cannot be applied to the primitive int type, how can i fix it?
Link to comment
Share on other sites
2 answers to this question
Recommended Posts