Skip to content

Instantly share code, notes, and snippets.

@wilzbach
Created August 1, 2016 15:08
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/ed5033e5be08b09dc181972a4f56fb7c to your computer and use it in GitHub Desktop.
Save wilzbach/ed5033e5be08b09dc181972a4f56fb7c to your computer and use it in GitHub Desktop.
FP magic fun on 32-bit
S fun(S)(in S x)
{
return -1 / x;
}
void main()
{
alias S = double; // same for float
S i = fun!S(3);
assert(i == S(-1) / 3); // this lines passes
assert(fun!S(3) == S(-1) / 3); // error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment