[swift-users] Swift support for long double/Float80 math functions?

Antonino Ficarra antonino.ficarra at gmail.com
Sat Jul 2 03:10:36 CDT 2016


How make Float80 bridge with long double math.h c functions?

I resorts to use some orrible hacks like these: 

// in f80.h
extern void sqrt_f80( void *result, const void *v );
extern void pow_f80( void *result, const void *v, const void *e );
...

// in f80.c
void sqrt_f80( void *result, const void *v )	{ *(long double *)result = sqrtl( *(const long double *)v ); }
void pow_f80( void *result, const void *v, const void *e )	{ *(long double *)result = powl( *(const long double *)v,*(const long double *)e ); }
…

// in f80.swift
func sqrt( _ a:Float80 ) -> Float80		{ var result = Float80(); var v = a; sqrt_f80( &result, &v ); return result; }
func pow( _ a:Float80,_ e:Float80 ) -> Float80 { var result = Float80(); var v1 = a; var v2 = e; pow_f80( &result, &v1, &v2 ); return result; }


There is an easier way?

P.S. Sorry for my bad english.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160702/c7720ff2/attachment.html>


More information about the swift-users mailing list