Math Processor Unit Library

libmpu – library of arithmetic functions for integer, real, and complex numbers of increased digit capacity

16 Commits   0 Branches   2 Tags
author: kx <kx@radix-linux.su> 2024-12-20 16:11:07 +0300 committer: kx <kx@radix-linux.su> 2024-12-20 16:11:07 +0300 commit: 868b2b66b564b5c00e3a74d10be45db7151627ac parent: cce2ae8d3312493b7653358bb4af201d3271377b
Commit Summary:
Version 1.0.14
Diffstat:
1 file changed, 42 insertions, 0 deletions
diff --git a/mpu/mpu-math-error.c b/mpu/mpu-math-error.c
new file mode 100644
index 0000000..e519c90
--- /dev/null
+++ b/mpu/mpu-math-error.c
@@ -0,0 +1,58 @@
+
+/***************************************************************
+  __MPU_MATH_ERROR.C
+
+       This file contains source code of functions for
+       MATH ERROOR operations.
+
+       PART OF : MPU - library .
+
+       USAGE   : Internal only .
+
+       NOTE    : NONE .
+
+       Copyright (C) 2000 - 2024  by Andrew V.Kosteltsev.
+       All Rights Reserved.
+ ***************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <nls.h>
+
+#include <errno.h>
+
+#include <libmpu.h>
+#include <mpu-context.h>
+#include <mpu-symbols.h>
+
+#include <mpu-math-errno.h>
+
+/*
+  __mpu_math_error() работает с внешним форматом чисел.
+
+  Пользователь может определить собственную функцию
+  __mpu_math_error() в качестве замены данного стандартного
+  обработчика математических ошибок.
+ */
+
+int __use_default_math_error = 1;
+
+int __mpu_math_error( struct __exception *pexcept )
+{
+  /* NOTE: ******************************************************
+       if( RETURN( 0 ) ) [ - ОШИБКА НЕ ОБРАБОТАНА]
+           надо печатать сообщение об ошибке и переменной ERRNO
+           присваивать соответствующее значение.
+       if( RETURN( 1 ) ) [ - ОШИБКА ОБРАБОТАНА]
+           сообщение об ошибке не печатается и значение переменной
+           ERRNO остается неизменным.
+   ***************************************************************/
+  if( pexcept->type == __INEXACT__ )
+  {
+    return( 1 );
+  }
+
+  return( 0 );
+}