[Mono-list] Math precision.
Thomas F. Burdick
tfb@OCF.Berkeley.EDU
Thu, 19 Jul 2001 11:50:10 -0700
Michael Meeks writes:
>
> Hi Bob,
>
> On 19 Jul 2001, Bob Smith wrote:
> > > I've been working on the System.Math class, trying to implement
> > > everything in C# without useing P/Invoke. I've been fairly successfull
> > > at implementing the trig functions like sin/cos,
>
> Your implementation, although interesting is never going to be as
> quick as the native versions of these functions built into modern
> processors. A 'sin' is a handful of cycles and can be interleaved with
> other floating point ops [ ok so not via PInvoke it can't :-], it would be
> hundreds of times more efficient to just invoke the C routine which should
> go to the co-proc.
I'd say use PInvoke for simplicity (if it's in the libc, we may as
well use it), and leave the question of efficiency to the JIT. If it
open-codes functions that have hardware built-ins, we'll win quite a
bit over going through PInvoke.