This page or section is in question as to whether it is useful or not. You can discuss whether you think it should be deleted or not on its talk page. (October 2023)Reason: Information is very loosely related to Scratch, sections of the article can be its own separate article or merged with others. |

A **fraction** is a rational number that is expressed as a single unit composed of a ratio of two or more values. Wikipedia defines a fraction as "any part of a unit". Decimal numbers are fractions written in a different format. For example, 0.5 is a fraction, as it represents the ratio "5/10" or "1/2". -1.4 and 5.67 are also fractions because they are decimal numbers. One-half of an apple is also a fraction of an apple. These numbers can also be called **decimal numbers** or **floating point numbers**.

An integer may even be written as a fraction. For example, the integer 2 may be written as "2/1" or "6/3". The numerator of a fraction is the value on the top; the denominator is the value on the bottom. Fractions may even contain other fractions inside of them. These are known as "complex fractions". The base operation relating to fractions is division; the numerator divided by the denominator can convert a fraction into a decimal format, which may be less exact.

## Glitches with Fractions

### Displaying Fractions on Screen

In Scratch, using a variable or an operation that can return a floating point number, attempting to go to that point can cause problems since a fraction of a pixel cannot exist on screen. Scratch normally handles this itself, but with certain decimal numbers, pen does not show up. This can be a problem for many projects, but is easily fixable. Instead of:

go to x: ((1)+(0.5)) y: ((1)+(0.5))

Use:

go to x: (round((1)+(0.5))) y: (round((1)+(0.5)))

### Floating Point Calculations

*Main article: Variable Decimal Glitch*

Because floating point numbers are represented with a finite number of binary digits, they are not always completely accurate, which makes results of some operations incorrect. For example, `([ceiling v] of (5.0))`

will return 6.^{[1]} Similar errors will happen when changing a variable by a negative fractional number. If you want to do this until the variable equals 0, the loop might never stop.

## Scratch's functions returning floating point numbers

Some of Scratch's functions will return fractions. For example, calculations performed with the `([ v] of ():: operators)`

block will almost always return a fraction.