NEARESTFRAC
A number rounded to the nearest fraction of an inch: halves, quarters, eighths, sixteenths … no finer than the largest denominator given.
Syntax
NEARESTFRAC(x,largest)
| Argument | Meaning |
|---|---|
| x | A number. |
| largest | The largest denominator: 2, 4, 8, 16, 32, 64, 128, 256 … |
Result
An exact fraction in lowest terms, its denominator a power of two no more than largest (a whole number if that is nearest).
Examples
In the example drawing:
| Expression | Gives |
|---|---|
NEARESTFRAC(0.3,16) |
5/16 |
NEARESTFRAC(2.49,4) |
2 1/2 |
NEARESTFRAC(0.333,256) |
85/256 |
NEARESTFRAC(25.4/7,16) |
3 5/8 |
NEARESTFRAC(0.999,16) |
1 |
NEARESTFRAC(0.3,100) |
19/64 |
Notes
The denominator is always a power of two, as rulers and tape measures divide an inch: a largest that isn't one counts
as the power of two below it (100 gives 64ths). A number exactly half way between two rounds away from zero. The
result is a fraction, so it stays exact in what is worked out from it (NEARESTFRAC(X,16)+1/16) and is shown as a
fraction, which suits sizes in inch drawings. largest must be a whole number, 1 or more.