User-facing numbers: implementing them efficient, "operational" and round-off safe?
<p>I have something similar to a <strong>spreadsheet column</strong> in mind. A spreadsheet column has transparent data typing: text or any kinds of numbers.</p>

<p>But no matter how the typing is implemented internally, they allow <strong>roundoff-safe</strong> operations; eg adding up a column of hundreds of numbers with decimal points, and other arithmetic operations. And they do it efficiently too.</p>

<p>What way of handling numbers can make them:</p>

<ol>
<li>transparent to the user</li>
<li>round-off safe</li>
<li>support efficient arithmetic, aggregation, sorting</li>
<li>handled by datastores and applications with Java primitive types?</li>
</ol>

<hr>

<p>I have in mind, using a 64b <code>long</code> datatype that is internally multiplied by 1000 to provide 3 decimal places. For example <code>123.456</code> is internally stored as <code>123456</code>, <code>`1</code> is stored as <code>1000</code>. Reinventing floating point numbers seems clunky; I have to reinvent multiplication, for example.</p>

<hr>

<p><strong>Miscellany:</strong> I actually have in mind a document tagging system. A number tag is conceptually similar to a spreadsheet column that is used to store numbers.</p>

<p>I do want to know how spreadsheets handle it, and I would have titled the question as such.</p>

<p>I am using two datastores that uses Java primitive types. Point #4 wasnt hypothetical.</p>
