c - comparing intervals using integers -
first off, know there many different easier/reliable ways perform ask, not point of question.
i attempting compare 2 sets of integers if fractions. mean suppose have 2d array:
int array[2][2]; array[0][0] = 2; array[0][1] = 3; array[1][0] = 1; array[1][1] = 50;
how want treat these numbers number in:
array[0][0] = 2 <--- numerator
array[0][1] = 3 <--- denominator
or 2/3 in case. want compare 2 fractions;
if(2/3 < 1/50){ //blah blah blah code here }
the caveat here can not convert numbers floating point numbers retain accuracy or create temporary floating point placeholder. there way compare these using integer values?
i don't know should tag question, if think of let me know , i'll tag it.
cross multiply 2 numerators 1 another's denominators
ie
2/3 vs 1/50th: multiply 50 , 1 3 , multiply 2 , 3 50.
then can compare numerator without having convert float.
Comments
Post a Comment