From owner-freebsd-hackers Sat Mar 10 21:36:10 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from gull.prod.itd.earthlink.net (gull.prod.itd.earthlink.net [207.217.121.85]) by hub.freebsd.org (Postfix) with ESMTP id DEAA037B718 for ; Sat, 10 Mar 2001 21:36:07 -0800 (PST) (envelope-from fmela0@sm.socccd.cc.ca.us) Received: from sm.socccd.cc.ca.us (pool0290.cvx14-bradley.dialup.earthlink.net [209.179.39.35]) by gull.prod.itd.earthlink.net (EL-8_9_3_3/8.9.3) with ESMTP id VAA28429; Sat, 10 Mar 2001 21:35:56 -0800 (PST) Message-ID: <3AAB0F18.E93A0506@sm.socccd.cc.ca.us> Date: Sat, 10 Mar 2001 21:37:28 -0800 From: Farooq Mela Reply-To: fmela0@sm.socccd.cc.ca.us X-Mailer: Mozilla 4.76 [en] (X11; U; FreeBSD 4.2-STABLE i386) X-Accept-Language: en MIME-Version: 1.0 To: Jordan DeLong Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel area libmish stuff References: <20010309175233.A6880@cx420564-b.tucson1.az.home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Jordan DeLong wrote: > I was thinking of just getting a sintable array and making a few simple > functions, so the whole of libm doesn't need to be statically linked into the > module (from my understanding, once loaded, this module wont ever get paged out, > and thus it'd be _bad_ for it to be big). Well, you can't do any FP stuff inside the kernel, as stated by others. But what you can do is use the fact that: sin(x) = x - (x^3)/3! + (x^5)/5! - (x^7)/7! ... and things like sin(-x) = -sin(x), etc, and integer arithmetic. You'd have to multiply X by a suitably large "base" value so that you dont have underflow, and compute it that way, and then divide the final answer by the base. Throughout your program, you'd have to change all your floating point arithmetic to use this sort of arithmetic - first multiplying by the base, doing all calculations, and dividing by the base once you arrive at the _final_ answer. A real pain, at best. The rest of the transcendental trig's can be built using identities like cos(x) = sin(x + pi/2), tan(x) = sin(x)/cos(x), etc. HTH -- farooq "Life's not fair, but the root password helps." -BOFH To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message