Created
July 17, 2014 16:13
Revisions
-
kosh04 created this gist
Jul 17, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ // see also: // http://msdn.microsoft.com/ja-jp/library/k3backsw.aspx // http://linuxjm.sourceforge.jp/html/LDP_man-pages/man3/matherr.3.html #define _SVID_SOURCE #include <math.h> #include <string.h> #include <stdio.h> #ifdef _WIN32 #define matherr _matherr #define exception _exception #endif int main(int argc, char **argv) { #ifdef __linux__ _LIB_VERSION = _SVID_; #endif printf("log(-2.0) = %e\n", log(-2.0)); printf("log10(-5.0) = %e\n", log10(-5.0)); printf("log(0.0) = %e\n", log(0.0)); return 0; } int matherr(struct exception *e) { if (e->type == DOMAIN) { if (strcmp(e->name, "log") == 0) { e->retval = log(-(e->arg1)); fprintf(stderr, "Special: using absolute value: %s: _DOMAIN error\n", e->name); return 1; } else if (strcmp(e->name, "log10") == 0) { e->retval = log10(-(e->arg1)); fprintf(stderr, "Special: using absolute value: %s _DOMAIN error\n", e->name); return 1; } } fprintf(stderr, "Normal: "); return 0; }