This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Oeps. Misreading on my side, you are right Jörg. Hmm, not sure if that is possible. You could do 1 divide it by the number you have 0.5, the result will be 2 then display 1/[result]. However that might create some ackward situation if the number isn't a full number I guess..

Comment

After a quick googling, I found a couple of articles on representing decimal numbers as fractions. I havent found a complete ready to use algorithm, but you can find some ideas by looking at the following articles :

Comment

The int argument of divide() is the rounding-mode which is used to round to the given scale (in your case the scale is 2).
Rounding mode 2 stands for ROUND_CEILING and 3 for ROUND_FLOOR. So that makes the difference.