[Cryptography] floating point

Tom Mitchell mitch at niftyegg.com
Thu Dec 25 18:37:18 EST 2014


On Tue, Dec 23, 2014 at 7:03 PM, John Denker <jsd at av8n.com> wrote:

> On 12/23/2014 02:05 PM, Dave Horsfall wrote:
>
> > I still remain astonished, that, since Babbage/Lovelace/Turing/etc, that
> > many alleged programmers still do not know that 0.0 != 0.


 Sigh...
This is so astoundingly opaque that those that say "don't do it
are correct" even without knowing why in a specific case.

I have seen a very long list of comparison permutations
both intended and unintended.
string--string
string--int
string--float
string--reference-to{string, float, double,int, long int,}
etc... etc...

Historically in C "0" was shorthand for int 0 but
could be 8 bits, 16 bits, 32 bits, 64 bits all zero.
signed and unsigned can complcate it all. Float
of size 32bit would be 0.0 but could have been 64bit.

Depending on the version of C and the compiler
promotions to float or something bigger might happen
or not.  Signed and unsigned is an additional tangle.
Demotion to smaller gets done by some.

Shell scripts are notorious...

In this case the compiler will see these as constants
and evaluate the expression and insert the answer
in the code and not "show the work".   When symbols
are involved propagation of type gets interesting.

So strictly type all constants and variables cast rarely
(iff needed. The use of assertions for anything that might be
compiler evaluated to a constant is worth the effort
and assert() can ultimately be free.

Programming language and API+ABI get involved
especially with languageA--languageB interfaces and calling conventions.

The key to cryptography here is to type each and every  "thing" so
the compiler knows what the author is drying to do.







-- 
  T o m    M i t c h e l l
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.metzdowd.com/pipermail/cryptography/attachments/20141225/23adda0f/attachment.html>


More information about the cryptography mailing list