Skip to content

Instantly share code, notes, and snippets.

@wilzbach
Created August 1, 2016 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilzbach/ec7cc9464e4e8f97689637f23238d510 to your computer and use it in GitHub Desktop.
Save wilzbach/ec7cc9464e4e8f97689637f23238d510 to your computer and use it in GitHub Desktop.
std.math.pow vs C pow
void main()
{
alias S = float;
S s1 = 0x1.24c92ep+5;
S s2 = -0x1.1c71c8p+0;
import std.math : std_pow = pow;
import core.stdc.stdio : printf;
import core.stdc.math: powf;
printf("std: %a\n", std_pow(s1, s2));
printf("pow: %a\n", s1 ^^ s2);
printf("pow: %a\n", powf(s1, s2));
version(LDC)
{
import ldc.intrinsics : llvm_pow;
printf("ldc: %a\n", llvm_pow(s1, s2));
}
}
std: 0x1.2c155ap-6
pow: 0x1.2c155ap-6
powf: 0x1.2c1558p-6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment