How are fractions represented in computers

Write fractions on the computer

Reading time: 13 min

We encounter fractions every day, we calculate with them (“half a pear”), we act according to them (“fill a third of the bottle with water”) and almost everyone knows the rules for calculating fractions.

But what do we do when we enter a fraction on the computer. So an input that should also look like a fraction. In the following, you will find out what options there are for this.

1. Enter fractions with a slash

Everyone has seen something like this:. A slash separates the from and correct, almost intuitively we know this is supposed to be a fraction, namely a half. The nice thing about this representation is that the slash is on the keyboard above the 7 key. So we just have to + press and we have the fraction line. In this way we can write down arbitrary fractions, even if there is a disadvantage: the numerator and denominator are on the same line, at the same height. It doesn't really look like a break, especially it becomes difficult to read when we have something like this for example:.

Be careful: some write something like and think to themselves, it's in the meter. However, this is one of the most common typing errors in math forums like the math lounge. Because it actually says that the division with the 6 is only applicable to the 2. Here you absolutely have to put a bracket around the entire term in the numerator, so it is correct as follows:. The same applies to the denominator, should be entered like this:. You can avoid mistakes here with brackets.

Alternative to the slash: Instead of the slash, you can also use the symbol for the fraction line, which is similar to the slash, but is a little more inclined. For comparison: and.

2. Fractions with a superscript numerator and a subscript denominator x/y in HTML

It is nicer to the eye and easier to see if we move the numerator up a little and the denominator down a little. This creates a better visual separation of the two. But how do you do that? If you can write some text for a website and can use HTML (and of course know how to enter HTML), this is pretty easy:

For you write down the HTML code:

is the day for superscript, in German "superscript" and is the day for subscript, in German "subscript". With these two tags you can move the text half a line up or down.

If you now use the fraction symbol, our fraction already looks like this:.

As we can see, we are getting closer to our goal. HTML code of the character is by the way

3. Fractions with a superscript numerator and a subscript denominator x/y in Microsoft Word

At this point we would like to point out that superscripts and subscripts are activated in Word. To do this, mark the text that you want to put in superscript or subscript and open the text format. There you can click "Superscript" or "Subscript" and the text will be changed accordingly. By the way, the shortcut or is handy here.

4. Enter fractions in Google Docs

Fractions can also be entered in Google Docs. To do this, select "Insert" in the menu above and then "Equation". Press the fraction in the submenu. This is then inserted.

5.Enter fractions in Microsoft Word (Equation)

Microsoft Word is comprehensive software that can not only be used to write. Word also includes options for entering fractions and displaying them correctly. To do this, you have to switch on the formula mode: press +. Then you enter:. This is the notation for a fraction. Then press + to turn off formula mode and get into the rendered view. Here is a quick GIF video tutorial.

The result looks like this:

6. Characters that are fractions

There are actually a few characters that directly represent fractions. They are also called HTML entities. There are:

¼ a quarter
½ a half
¾ three quarters

You can now copy and paste them into your text if you need these fractions. Otherwise they have no use for you. If you have to write it down in HTML, use: for ¼ | for ½ | for ¾.

7. Display breaks with HTML and CSS really nicely

With a little CSS (Cascading Style Sheets) that can be used to design HTML elements, we can make a fraction look like a fraction. Here is an example from the online quadratic equations calculator:

x1,2 = -b ± √b² - 4 * a * c/2 a

And that's really nice. Numerator at the top, denominator at the bottom. Optically recognizable. And how does it work?

For the break a/b write down the following HTML:

And for this you still need the CSS style instructions:

You bring the HTML and CSS together and you have a considerable break.

The only drawback: If you write several fractions next to each other, the operation signs are at the bottom of the line and unfortunately not at the level of the fraction line:

a/b + a/b

Here one would have to additionally style the operation signs. For example, one achieves the desired success with, the plus sign is shifted a little upwards:
a/b+a/b

8. Represent fractions with LaTeX

The ultimate tool for representing fractions and many mathematical symbols is LaTeX. LaTeX or TeX is a notation / notation for mathematical characters, a so-called typesetting system. The input is made with the keyboard, formatting and mathematical characters are entered in text form and converted afterwards.

Example:

You can find more information here: LaTeX Assistant