fractions

How to write fraction value using html?

*爱你&永不变心* 提交于 2019-11-26 08:20:09
问题 I want to write fraction value such as the picture below: How do I write fraction value using html without using image? NOTE: I don\'t want this 1 1/2 pattern but strictly just as the pic above 回答1: Try the following: 1<sup>1</sup>⁄<sub>2</sub> This displays as: 1 1 ⁄ 2 回答2: .frac { display: inline-block; position: relative; vertical-align: middle; letter-spacing: 0.001em; text-align: center; } .frac > span { display: block; padding: 0.1em; } .frac span.bottom { border-top: thin solid black;

Best way to represent a fraction in Java?

眉间皱痕 提交于 2019-11-26 02:29:50
问题 I\'m trying to work with fractions in Java. I want to implement arithmetic functions. For this, I will first require a way to normalize the functions. I know I can\'t add 1/6 and 1/2 until I have a common denominator. I will have to add 1/6 and 3/6. A naive approach would have me add 2/12 and 6/12 and then reduce. How can I achieve a common denominator with the least performance penalty? What algorithm is best for this? Version 8 (thanks to hstoerr): Improvements include: the equals() method