From: "Frank Bemelman"
References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org> <email@example.com>
Subject: Re: Trig circuits
Date: Mon, 23 Dec 2002 22:41:12 +0100
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
Organization: EuroNet Internet
NNTP-Posting-Date: 23 Dec 2002 21:42:40 GMT
"Spehro Pefhany" schreef in bericht
> On Mon, 23 Dec 2002 19:26:23 +0100, the renowned "Frank Bemelman"
> >And 4) Never use 'if(((float)x==(float)y) && ((float)m!=(float)n))'.
> Why, Frank? What could happen? ;-)
Very likely not very much ;)
> >I hate floats ;)
> They have their place. It's nicer to be able to have the luxury of
> a high-volume job where you can craft bespoke math routines that
> have just what is required, but for quick and dirty < 5K pcs.
> volume, when cost and performance isn't as important as getting
> a solid and reliable solution out the door, compilers generally do
> the trick.
Yes, they have their place. But all too often I see floats used
by lazy folks from who I inherited code that is only good to be
fed to the office schredder, which I do happily and frequently.
If that was the worst problem, okay, but whenever I use floats
in my not so clever and fuzzy code, my functions start to spit
NAN's at me, very unpolite indeed.
> One that I'm working on now is about 80-90% C, with assembler to do
> some fast 24-bit + 16 bit unsigned addition as well as a few
> other things. I had to write a couple of bastardized C-asm
> routines for unsigned * and / because I couldn't afford the library
> space for longs (only 1K words total code space for everything).
That's the trouble with 8 bits. It takes a lot of time too,
to do 32bit calculations on an 8 bit uP. Not something you
want to do all the time.
> If I had to do a *single* function like sin(x) for a volume
> cost-sensitive product, I'd use some things from the bag 'o tricks
> such as polynomials or even a LUT with interpolation. It's
> easy enough to curve-fit and generate whatever accuracy is
> required. I find this stuff kind of fun, but often can't
> justify it these days with processing power so cheap. Consider
> the MSP430 family- 60K of code space, a fast low-power 16 bit
> processor, with 12-bit ADC and cost is less than $6 USD in volume.
> There may even be a usable free compiler for it now.
I would like to give that MSP430 a try, but I'm not doing any
important hardware, more into software at the moment. Next year
there is a good chance I find myself programming SCADA applications
and I don't like it a bit :(
(remove 'x' & .invalid when sending email)