home: hub: 9ficl

ref: 7e8060a09c49aabd3a65154d30639456c7326053
dir: /math64.h/

View raw version
/*******************************************************************
** m a t h 6 4 . h
** Forth Inspired Command Language - 64 bit math support routines
** Author: John Sadler (john_sadler@alum.mit.edu)
** Created: 25 January 1998
** $Id: math64.h,v 1.4 2001/04/25 18:58:48 jsadler Exp $
*******************************************************************/
/*
** Get the latest Ficl release at http://ficl.sourceforge.net
**
** L I C E N S E  and  D I S C L A I M E R
** 
** Ficl is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
** 
** The ficl software code is provided on an "as is"  basis without
** warranty of any kind, including, without limitation, the implied
** warranties of merchantability and fitness for a particular purpose
** and their equivalents under the laws of any jurisdiction.  
** See the GNU Lesser General Public License for more details.
** 
** To view the GNU Lesser General Public License, visit this URL:
** http://www.fsf.org/copyleft/lesser.html
** 
** Any third party may reproduce, distribute, or modify the ficl
** software code or any derivative  works thereof without any 
** compensation or license, provided that the author information
** and this license text are retained in the source code files.
** 
** I am interested in hearing from anyone who uses ficl. If you have
** a problem, a success story, a defect, an enhancement request, or
** if you would like to contribute to the ficl release (yay!), please
** send me email at the address above. 
*/

#if !defined (__MATH64_H__)
#define __MATH64_H__

#ifdef __cplusplus
extern "C" {
#endif

DPINT   m64Abs(DPINT x);
int     m64IsNegative(DPINT x);
DPUNS   m64Mac(DPUNS u, FICL_UNS mul, FICL_UNS add);
DPINT   m64MulI(FICL_INT x, FICL_INT y);
DPINT   m64Negate(DPINT x);
INTQR   m64FlooredDivI(DPINT num, FICL_INT den);
void    i64Push(FICL_STACK *pStack, DPINT i64);
DPINT   i64Pop(FICL_STACK *pStack);
void    u64Push(FICL_STACK *pStack, DPUNS u64);
DPUNS   u64Pop(FICL_STACK *pStack);
INTQR   m64SymmetricDivI(DPINT num, FICL_INT den);
UNS16   m64UMod(DPUNS *pUD, UNS16 base);


#if PORTABLE_LONGMULDIV != 0   /* see sysdep.h */
DPUNS   m64Add(DPUNS x, DPUNS y);
DPUNS   m64ASL( DPUNS x );
DPUNS   m64ASR( DPUNS x );
int     m64Compare(DPUNS x, DPUNS y);
DPUNS   m64Or( DPUNS x, DPUNS y );
DPUNS   m64Sub(DPUNS x, DPUNS y);
#endif

#define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 0 
#define m64CastIU(i64) (*(DPUNS *)(&(i64)))
#define m64CastUI(u64) (*(DPINT *)(&(u64)))
#define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr)))
#define m64CastQRUI(uqr) (*(INTQR *)(&(uqr)))

#define CELL_HI_BIT (1L << (BITS_PER_CELL-1))

#ifdef __cplusplus
}
#endif

#endif