C interop
Raw C islands next to NanoC code: call libm and your own C helper functions.
+ <stdio.h>
+ <math.h>
@c
static double hyp(double a, double b) { return sqrt(a * a + b * b); }
f main()
printf("hypot(3,4) = %g\n", hyp(3, 4))
printf("cbrt(27) = %g\n", cbrt(27))
< 0
#include <stdio.h>
#include <math.h>
static double hyp(double a, double b) { return sqrt(a * a + b * b); }
int main(void) {
printf("hypot(3,4) = %g\n", hyp(3, 4));
printf("cbrt(27) = %g\n", cbrt(27));
return 0;
}
Output
hypot(3,4) = 5
cbrt(27) = 3
What it shows
@c, libm