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

/***************************************************************
  __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 );
}