math64.h revision 40843
1/*******************************************************************
2** m a t h 6 4 . h
3** Forth Inspired Command Language - 64 bit math support routines
4** Author: John Sadler (john_sadler@alum.mit.edu)
5** Created: 25 January 1998
6**
7*******************************************************************/
8/*
9** N O T I C E -- DISCLAIMER OF WARRANTY
10**
11** Ficl is freeware. Use it in any way that you like, with
12** the understanding that the code is not supported.
13**
14** Any third party may reproduce, distribute, or modify the ficl
15** software code or any derivative  works thereof without any
16** compensation or license, provided that the author information
17** and this disclaimer text are retained in the source code files.
18** The ficl software code is provided on an "as is"  basis without
19** warranty of any kind, including, without limitation, the implied
20** warranties of merchantability and fitness for a particular purpose
21** and their equivalents under the laws of any jurisdiction.
22**
23** I am interested in hearing from anyone who uses ficl. If you have
24** a problem, a success story, a defect, an enhancement request, or
25** if you would like to contribute to the ficl release (yay!), please
26** send me email at the address above.
27*/
28
29#if !defined (__MATH64_H__)
30#define __MATH64_H__
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36INT64 m64Abs(INT64 x);
37int   m64IsNegative(INT64 x);
38UNS64 m64Mac(UNS64 u, UNS32 mul, UNS32 add);
39INT64 m64MulI(INT32 x, INT32 y);
40INT64 m64Negate(INT64 x);
41INTQR m64FlooredDivI(INT64 num, INT32 den);
42void  i64Push(FICL_STACK *pStack, INT64 i64);
43INT64 i64Pop(FICL_STACK *pStack);
44void  u64Push(FICL_STACK *pStack, UNS64 u64);
45UNS64 u64Pop(FICL_STACK *pStack);
46INTQR m64SymmetricDivI(INT64 num, INT32 den);
47UNS16 m64UMod(UNS64 *pUD, UNS16 base);
48
49#define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 0
50#define m64CastIU(i64) (*(UNS64 *)(&(i64)))
51#define m64CastUI(u64) (*(INT64 *)(&(u64)))
52#define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr)))
53#define m64CastQRUI(uqr) (*(INTQR *)(&(uqr)))
54
55#ifdef __cplusplus
56}
57#endif
58
59#endif
60
61