From: Peter Williams <pwil3058@bigpond.net.au>
To: Ian Kent <raven@themaw.net>
Cc: ndiamond@despammed.com, linux-kernel@vger.kernel.org
Subject: Re: How to use floating point in a module?
Date: Mon, 31 May 2004 16:13:21 +1000 [thread overview]
Message-ID: <40BACD01.5000106@bigpond.net.au> (raw)
In-Reply-To: <Pine.LNX.4.58.0405311340450.4198@wombat.indigo.net.au>
Ian Kent wrote:
> On Sun, 30 May 2004 ndiamond@despammed.com wrote:
>
>
>>Yes, if we use a real-time Linux and make a daemon cooperate very closely
>>with the driver.
>>
>>
>>>Maybe you could use lookup tables instead of doing floating point
>>>arithmetic.
>>
>>You might be right, if the device can only be controlled to position itself
>>in say 1,000 different ways, then we could have lookup tables for 1,000
>>different intervals of (emulations of) floating-point numbers, that yield
>>1,000 different values of sin. Another table for cos, another for log10,
>>etc. But I'd still have to write my own emulations for binary operators
>>such as +, /, etc., since a 1,000*1,000 lookup table would be too big.
>
>
> Why not scaled longs (or bigger), scalled to number of significant
> digits. The Taylor series for the trig functions might be a painfull.
See the "Handbook of Mathematical Functions" by Abromawitz and Stegun,
Dover Publications (ISBN 486-61272-2, Library of Congress number
65-12253) which has some small but accurate polynomial approximations
for many functions. I have used these successfully with fixed point
rational numbers (FDRN) (which are probably the same as your scaled
longs) using 64 bit integers and the results were generally accurate to
the least significant bit when compared to values calculated using the
normal maths library and converted to FDRN representation.
Of course, the available range of values is smaller than for floats or
double and you have to be careful w.r.t. overflow etc.
Peter
--
Dr Peter Williams pwil3058@bigpond.net.au
"Learning, n. The kind of ignorance distinguishing the studious."
-- Ambrose Bierce
next prev parent reply other threads:[~2004-05-31 6:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-05-31 2:50 How to use floating point in a module? ndiamond
2004-05-31 4:02 ` Chris Friesen
2004-05-31 5:44 ` Ian Kent
2004-05-31 6:13 ` Peter Williams [this message]
2004-05-31 13:39 ` Horst von Brand
2004-05-31 20:12 ` Michal Jaegermann
2004-05-31 20:23 ` Hugo Mills
2004-05-31 22:43 ` Peter Williams
-- strict thread matches above, loose matches on Subject: below --
2004-06-02 5:52 ndiamond
2004-06-02 19:31 ` Valdis.Kletnieks
2004-06-01 2:27 ndiamond
2004-06-01 0:38 ndiamond
2004-06-01 20:52 ` H. Peter Anvin
2004-05-31 20:38 Manfred Spraul
2004-05-31 21:11 ` Horst von Brand
2004-05-31 1:52 ndiamond
2004-05-31 2:18 ` Måns Rullgård
2004-05-30 22:39 ` Calvin Spealman
2004-05-31 4:28 ` Linus Torvalds
2004-05-31 3:57 ` Calvin Spealman
2004-05-31 3:59 ` Matt Mackall
2004-05-31 4:11 ` Stephen Smoogen
2004-05-31 14:55 ` Scott Robert Ladd
2004-06-01 2:11 ` Richard B. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=40BACD01.5000106@bigpond.net.au \
--to=pwil3058@bigpond.net.au \
--cc=linux-kernel@vger.kernel.org \
--cc=ndiamond@despammed.com \
--cc=raven@themaw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox