TIP: Click on subject to list as thread! ANSI
echo: quik_bas
to: RICK PEDLEY
from: DAVID WILLIAMS
date: 1998-05-01 09:42:00
subject: Help needed (geometry cod

-> Ah.. no :) But as can see you.. I mean, as you can see, by setting
-> constants equal to 2*PI and PI/2, we've already eliminated two FP
-> operations. There is also a technique, often used in financial
-> calculations, of temporarily scaling up all FP numbers by several
-> orders of magnitude (e.g. 3.1416 becomes 31416) and doing all
-> calculations with long integers, then returning the decimal to its
-> proper position in the solution. Much faster. I notice in some of the
-> code you posted a DEFDBL but perhaps only single precision was
-> required, again a small speed increase. But as you note in a later
-> message, the original poster was never heard from again, so I think
-> we would be wasting time taking this further without any input
Actually, I have heard from the original poster via private netmail. I
guess he prefers to keep a low profile.
Anyway, regardless of what his question was, the more general issues you
raise are clearly interesting. Yes, it is (usually) true that arithmetic
with integers is faster than with single-precision floating-point
numbers, which in turn are faster than double-precision ones. (Although
I remember the old Commodore BASIC which supported integer-format
variables, e.g. X%, but turned the numbers into floating-point when
doing arithmetic with them. So using the integer variables was actually
slower than not using them!) So scaling numbers upward by powers of ten
(or of two) until integer arithmetic can be used is usually helpful. And
DEFSNG is faster than DEFDBL, though not as precise. However, there are
obviously trade-offs. How much precision is a millisecond worth? Is the
thing intended for aligning an astronomical telescope, in which case
precision of a few microradians might be needed, or for laying our
flower beds, in which case anything within a few degrees might be fine?
Is the calculation going to be done a billion times, in which case
shaving a few milliseconds off it would save a lot of time in the long
run, or only a few times, in which case it might be better to save
*programming* time by doing things in conceptually simple ways?
These, of course, are general questions that apply in very many
situations, not just this one...
                              dow
--- PCBoard (R) v15.3 (OS/2) 5
---------------
* Origin: FidoNet: CAP/CANADA Support BBS : 416 287-0234 (1:250/710)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.