help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Musing about numbers


From: ghaverla
Subject: Musing about numbers
Date: Thu, 20 Feb 2014 17:03:43 -0700

I am currently trying to bundle some Perl stuff up to put on Savannah,
but maybe parts of the philosophy are of interest here.  Where it
mentions "on some architectures", I don't know which do or don't.  I
haven't looked into it deeply enough yet.  I still have some Octave
stuff on my TODO list.

In Perl, a variable can be string or number.  Numbers can be either
integer or double.  Integer division on floating point is not something
you normally should be doing (remainders), unless the dividend is a
power of 2.  I have been trying to get a count (integer) to be forced
into a float format, but it is hard to tell if its successful (multiply
by 1.0 and add 0.0).  I think benchmarking is the only way to verify
whether this is successful.

Some architectures apparently have a fast inverse for 1/$x, where you
have to use integer 1 for the numerator to trigger the fast operation.

On some architectures, floating point comparisons are slow.

If you are going to add a _lot_ to floating point numbers together, it
might be useful to sort them first.  Where you have pairs of the same
number present, doing a multiply by integer 2 may be significantly
faster than a floating point add.  It probably does not have roundoff
error.  Multiplication is usually faster than division, but can a
person write source code to indicate that a multiplication is to be
seen as a division?  This is mostly a maintenance of code issue.

Those are some thing I have picked up on, it is likely there are
others.  But if the object is to write portable code in whatever
language, at times it doesn't seem to be easy.

Gord



reply via email to

[Prev in Thread] Current Thread [Next in Thread]