About a project of processing .. I need a help

To do it properly is is quite tricky see Problems with fractions - #3 by monkstone if you are still stuck. Look up ApacheMath implementation.