Dmitry Wolf

# Programming languages basic types

## Integer

## Float ( Single )

```
Radix: Base 2 representation
Size: 32bit
Hardware supported
7 digits
```

## Double

```
Radix: Base 2 representation
Size: 64bit
Hardware supported
15-16 digits
Scientific calculations 10^(+/-300)
Fast calc, Infinity, NAN, -0 support, large/small numbers
http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html#1374
http://en.wikipedia.org/wiki/Floating_point#Accuracy_problems
```

## Decimal

```
Radix: Base 10 representation
Size: 128bit
Not hardware supported
28-29 significant digits
base 10 accuracy
when you work with values in the range of 10^(+/-28) and where you have expectations about the behaviour based on base 10 representations.
Always use for money.
Support specific rounding modes.
```

# .Net rounding

```
To nearest even number
Math.Round(3.5) == Math.Round(4.5)
5 == Math.Round(4.5, MidpointRounding.AwayFromZero)
```

# Equality

- Rounding, then comparision
- Fixed precision comparasion (epsilon)
- Relative precision comparasion