math64.h revision 40843
140843Smsmith/*******************************************************************
240843Smsmith** m a t h 6 4 . h
340843Smsmith** Forth Inspired Command Language - 64 bit math support routines
440843Smsmith** Author: John Sadler (john_sadler@alum.mit.edu)
540843Smsmith** Created: 25 January 1998
640843Smsmith**
740843Smsmith*******************************************************************/
840843Smsmith/*
940843Smsmith** N O T I C E -- DISCLAIMER OF WARRANTY
1040843Smsmith**
1140843Smsmith** Ficl is freeware. Use it in any way that you like, with
1240843Smsmith** the understanding that the code is not supported.
1340843Smsmith**
1440843Smsmith** Any third party may reproduce, distribute, or modify the ficl
1540843Smsmith** software code or any derivative  works thereof without any
1640843Smsmith** compensation or license, provided that the author information
1740843Smsmith** and this disclaimer text are retained in the source code files.
1840843Smsmith** The ficl software code is provided on an "as is"  basis without
1940843Smsmith** warranty of any kind, including, without limitation, the implied
2040843Smsmith** warranties of merchantability and fitness for a particular purpose
2140843Smsmith** and their equivalents under the laws of any jurisdiction.
2240843Smsmith**
2340843Smsmith** I am interested in hearing from anyone who uses ficl. If you have
2440843Smsmith** a problem, a success story, a defect, an enhancement request, or
2540843Smsmith** if you would like to contribute to the ficl release (yay!), please
2640843Smsmith** send me email at the address above.
2740843Smsmith*/
2840843Smsmith
2940843Smsmith#if !defined (__MATH64_H__)
3040843Smsmith#define __MATH64_H__
3140843Smsmith
3240843Smsmith#ifdef __cplusplus
3340843Smsmithextern "C" {
3440843Smsmith#endif
3540843Smsmith
3640843SmsmithINT64 m64Abs(INT64 x);
3740843Smsmithint   m64IsNegative(INT64 x);
3840843SmsmithUNS64 m64Mac(UNS64 u, UNS32 mul, UNS32 add);
3940843SmsmithINT64 m64MulI(INT32 x, INT32 y);
4040843SmsmithINT64 m64Negate(INT64 x);
4140843SmsmithINTQR m64FlooredDivI(INT64 num, INT32 den);
4240843Smsmithvoid  i64Push(FICL_STACK *pStack, INT64 i64);
4340843SmsmithINT64 i64Pop(FICL_STACK *pStack);
4440843Smsmithvoid  u64Push(FICL_STACK *pStack, UNS64 u64);
4540843SmsmithUNS64 u64Pop(FICL_STACK *pStack);
4640843SmsmithINTQR m64SymmetricDivI(INT64 num, INT32 den);
4740843SmsmithUNS16 m64UMod(UNS64 *pUD, UNS16 base);
4840843Smsmith
4940843Smsmith#define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 0
5040843Smsmith#define m64CastIU(i64) (*(UNS64 *)(&(i64)))
5140843Smsmith#define m64CastUI(u64) (*(INT64 *)(&(u64)))
5240843Smsmith#define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr)))
5340843Smsmith#define m64CastQRUI(uqr) (*(INTQR *)(&(uqr)))
5440843Smsmith
5540843Smsmith#ifdef __cplusplus
5640843Smsmith}
5740843Smsmith#endif
5840843Smsmith
5940843Smsmith#endif
6040843Smsmith
61