Skip to content

Instantly share code, notes, and snippets.

@cartazio
Last active February 11, 2019 16:27
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 cartazio/b7808e598686c1c025df022aff24ac3a to your computer and use it in GitHub Desktop.
Save cartazio/b7808e598686c1c025df022aff24ac3a to your computer and use it in GitHub Desktop.
NAN NAN you cant get the undefined float value man
install("inline")# not needed after the first time
library("inline")
nanBoom <- cfunction(c(dummy="ANY"),body="
fenv_t fenv;
unsigned int new_excepts = FE_DIVBYZERO | FE_INVALID ;
fegetenv(&fenv);
fenv.__mxcsr &= ~(new_excepts << 7);
fesetenv(&fenv);
return dummy;
",includes="#include <fenv.h>",language="C")
nanBoom(1)
0.0 /0.0# then R exits silently with SIGFPE and no error handling support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment