Skip to content

Instantly share code, notes, and snippets.

@cartazio cartazio/fixYoMath.r
Last active Feb 11, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.