M6 KVM avatar M6 KVM committed 4705dc4

Code from the svn tree, long unmaintained.

Comments (0)

Files changed (27)

+#error ("DLMath.C is no longer supported, the functions it contained were granulated, see Overlord")
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\Pow.H"
+
+unsigned int powi(unsigned int x, unsigned int y)
+{
+  unsigned int i; /* Loop variable */
+  unsigned int r = 1; /* value that is returned */
+  for (i=1;i<=y;i++)
+  {
+    r *= x;
+  }
+  if (x == 0) r = 0;
+  return r; /* give result */
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\Pow.H"
+
+unsigned long powli(unsigned long x, unsigned long y)
+{
+  unsigned long i;
+  unsigned long r = 1;
+  for (i=1;i<=y;i++)
+  {
+    r *= x;
+  }
+  if (x == 0) r = 0;
+  return r;
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\Pow.H"
+
+unsigned short powsi(unsigned short x, unsigned short y)
+{
+  unsigned short i;
+  unsigned short r = 1;
+  for (i=1;i<=y;i++)
+  {
+    r *= x;
+  }
+  if (x == 0) r = 0;
+  return r;
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+
+double dFactorial(double n)
+{
+	double Result = 1;
+   int i; /* Loop variable. */
+
+   /* Now loop through.  Each time through the loop
+      Multiply the result by i. */
+   for (i=1;i<=n;i++)
+   	Result *= i;
+   return Result;
+
+   /* by Michael Hyman */
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+
+long lFactorial(short n)
+{
+	long Result = 1;
+   long i; /* Loop variable. */
+
+   /* Now loop through.  Each time through the loop */
+   /* Multiply the result by i. */
+   for (i=1;i<=n;i++)
+   	Result *= i;
+   return Result;
+
+   /* by Michael Hyman */
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+
+long double ldFactorial(double n)
+{
+	long double Result = 1;
+   long double i; /* Loop variable. */
+
+   /* Now loop through.  Each time through the loop
+      Multiply the result by i. */
+   for (i=1;i<=n;i++)
+   	Result *= i;
+   return Result;
+
+   /* by Michael Hyman */
+}
+#include "Stds\DLStdInc.H"
+#pragma hdrstop
+
+#include "Math\Headers\DLMath.H"
+
+MONSTERLONG64* ml64CompDWORD(const MONSTERLONG64* PML64_A, const DWORD DW_B, BOOL* BisGreater)
+{
+  /* locals */
+  static MONSTERLONG64 promDW64; /* Promoted DWORD */
+
+  /* Promote DWORD to QWORD */
+  promDW64.hi = 0UL;
+  promDW64.lo = DW_B;
+
+  /* ...and pass on to QWORD processing function (laziness) */
+  return ml64Compml64(PML64_A, &promDW64, BisGreater);
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+
+void ml64MultiplyDWORD(MONSTERLONG64* PML64, const DWORD New32)
+{
+  if (PML64 && New32) /* Pointer sent and multiply by sent? */
+  {
+    DWORD i;
+    for (i = 0; i < New32; i++) /* Amount of multiplies to do */
+    {
+      ml64Addml64(PML64, PML64); /* Add number to itself */
+    }
+  }
+}
+/* The ml64 library is a C based library conforming to ANSI C (1990) as far
+as I know, this object attempts to encapsule the 64-bit type as an object.
+The functions are made available within the object.  A C++ implementation
+is available too, but as a completely seperate file outside of the math
+library to avoid problems.
+
+Programmer: Overlord David Duncan Ross Palmer
+Copyright: Daybo Logic, 1999
+Created: 22nd Dec 1999
+Last modified: [SAME]
+Revision: --->("0")<---
+THERE IS NO HISTORY
+*/
+
+#include <Assert.H>
+#include <String.H>
+#include "Stds\DLStdInc.H" /* Daybo Logic standard inclusions */
+#pragma hdrstop
+
+#include "Math\Headers\ml64.H"
+/*-------------------------------------------------------------------------*/
+/* All of these are in someway exposed to outsiders even if through pointers */
+static void S_MONSTERLONG64_Addml64(void*, const MONSTERLONG64* New64);
+static void S_MONSTERLONG64_AddDWORD(void*, const DWORD New32);
+static void S_MONSTERLONG64_AddWORD(void*, const WORD New16);
+static MONSTERLONG64* S_MONSTERLONG64_RandomGenerate(void*, PS_ML64RNDGEN_OPTIONS Poptions);
+static void S_MONSTERLONG64_Subml64(void*, const MONSTERLONG64* Sub64);
+static void S_MONSTERLONG64_SubDWORD(void*, const DWORD Sub32);
+static void S_MONSTERLONG64_SubWORD(void*, const WORD Sub16);
+static MONSTERLONG64* S_MONSTERLONG64_Compml64(void*, const MONSTERLONG64* PML64_B, BOOL* BisGreater);
+static MONSTERLONG64* S_MONSTERLONG64_CompDWORD(void*, const DWORD DW_B, BOOL* BisGreater);
+static MONSTERLONG64* S_MONSTERLONG64_CompWORD(void*, const WORD DW_B, BOOL* BisGreater);
+static BOOL S_MONSTERLONG64_QuerySignBit(void*);
+static void S_MONSTERLONG64_SetSignBit(void*, const BOOL SetOrClear);
+static void S_MONSTERLONG64_MultiplyDWORD(void*, const DWORD New32);
+static void S_MONSTERLONG64_MultiplyWORD(void*, const WORD New16);
+void S_MONSTERLONG64_Construct(PS_MONSTERLONG64 PObject);
+void S_MONSTERLONG64_ConstructAndInit(PS_MONSTERLONG64 PObject, MONSTERLONG64* InitVal);
+/* These are not available to outsiders */
+static void S_MONSTERLONG64_Init(PS_MONSTERLONG64 PObject); /* Data init */
+static void S_MONSTERLONG64_Linkup(PS_MONSTERLONG64 PObject); /* Member function linkup or reset of redirections */
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_Addml64(void* PObject, const MONSTERLONG64* New64)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64Addml64(&s->_ml64, New64); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_AddDWORD(void* PObject, const DWORD New32)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64AddDWORD(&s->_ml64, New32); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_AddWORD(void* PObject, const WORD New16)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64AddWORD(&s->_ml64, New16); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static MONSTERLONG64* S_MONSTERLONG64_RandomGenerate(void* PObject, PS_ML64RNDGEN_OPTIONS Poptions)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  return ml64RandomGenerate(Poptions, &s->_ml64); /* Call ml64 library */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_Subml64(void* PObject, const MONSTERLONG64* Sub64)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64Subml64(&s->_ml64, Sub64); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_SubDWORD(void* PObject, const DWORD Sub32)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64SubDWORD(&s->_ml64, Sub32); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_SubWORD(void* PObject, const WORD Sub16)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64SubWORD(&s->_ml64, Sub16); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static MONSTERLONG64* S_MONSTERLONG64_Compml64(void* PObject, const MONSTERLONG64* PML64_B, BOOL* BisGreater)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  return ml64Compml64(&s->_ml64, PML64_B, BisGreater);
+}
+/*-------------------------------------------------------------------------*/
+static MONSTERLONG64* S_MONSTERLONG64_CompDWORD(void* PObject, const DWORD DW_B, BOOL* BisGreater)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  return ml64CompDWORD(&s->_ml64, DW_B, BisGreater);
+}
+/*-------------------------------------------------------------------------*/
+static MONSTERLONG64* S_MONSTERLONG64_CompWORD(void* PObject, const WORD W_B, BOOL* BisGreater)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  return ml64CompWORD(&s->_ml64, W_B, BisGreater);
+}
+/*-------------------------------------------------------------------------*/
+static BOOL S_MONSTERLONG64_QuerySignBit(void* PObject)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  return ml64QuerySignBit(&s->_ml64); /* Call ml64 library */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_SetSignBit(void* PObject, const BOOL SetOrClear)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64SetSignBit(&s->_ml64, SetOrClear); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_MultiplyDWORD(void* PObject, const DWORD New32)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64MultiplyDWORD(&s->_ml64, New32); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_MultiplyWORD(void* PObject, const WORD New16)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+  ml64MultiplyWORD(&s->_ml64, New16); /* Call ml64 library */
+  return; /* Done */
+}
+/*-------------------------------------------------------------------------*/
+void S_MONSTERLONG64_Construct(PS_MONSTERLONG64 PObject)
+{
+  S_MONSTERLONG64_Init(PObject); /* Init data members */
+  S_MONSTERLONG64_Linkup(PObject); /* Linkup member functions */
+}
+/*-------------------------------------------------------------------------*/
+void S_MONSTERLONG64_ConstructAndInit(PS_MONSTERLONG64 PObject, MONSTERLONG64* InitVal)
+{
+  S_MONSTERLONG64_Init(PObject); /* Init data members */
+  if (InitVal) /* initial value sent? */
+    PObject->_ml64 = *InitVal; /* Use it */
+  S_MONSTERLONG64_Linkup(PObject); /* Linkup member functions */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_Init(PS_MONSTERLONG64 PObject)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+
+  memset( &s->_ml64, 0, sizeof(s->_ml64) ); /* Init data */
+}
+/*-------------------------------------------------------------------------*/
+static void S_MONSTERLONG64_Linkup(PS_MONSTERLONG64 PObject)
+{
+  PS_MONSTERLONG64 s = (S_MONSTERLONG64*)PObject; /* Cast to make a 'this' pointer */
+
+  /* VTABLE */
+  s->Addml64          = S_MONSTERLONG64_Addml64;
+  s->AddDWORD         = S_MONSTERLONG64_AddDWORD;
+  s->AddWORD          = S_MONSTERLONG64_AddWORD;
+  s->RandomGenerate   = S_MONSTERLONG64_RandomGenerate;
+  s->Subml64          = S_MONSTERLONG64_Subml64;
+  s->SubDWORD         = S_MONSTERLONG64_SubDWORD;
+  s->SubWORD          = S_MONSTERLONG64_SubWORD;
+  s->Compml64         = S_MONSTERLONG64_Compml64;
+  s->CompDWORD        = S_MONSTERLONG64_CompDWORD;
+  s->CompWORD         = S_MONSTERLONG64_CompWORD;
+  s->QuerySignBit     = S_MONSTERLONG64_QuerySignBit;
+  s->SetSignBit       = S_MONSTERLONG64_SetSignBit;
+  s->MultiplyDWORD    = S_MONSTERLONG64_MultiplyDWORD;
+  s->MultiplyWORD     = S_MONSTERLONG64_MultiplyWORD;
+
+  return; /* Linkup complete */
+}
+/*-------------------------------------------------------------------------*/

C/ml64/Readme.txt

+ml64 library
+------------
+Written and documented by Overlord David Duncan Ross Palmer:
+
+The MONSTERLONG64 library deals with the MONSTERLONG64 type only,
+the MONSTERLONG64 type is a simple structure which contains a
+lo and a hi DWORD and is ANSI C (1990) compatible.  ANSI C (1990)
+did not contain a type which could hold 64-bit integers which is
+why I invented this type, it is inefficient if a 64-bit Processor is
+available with the programmer's will to violate ANSI C.
+
+9th Dec 1999 - I'll ****ing look back at this in years to come and
+               laugh! - OVERLORD DDRP
+#include <StdLib.H> /* The standard C library */
+#include <String.H> /* For memset(), I hope it's always in String.H! */
+#include <Time.H>
+#include "Stds\DLStdInc.H" /* The Daybo Logic standard inclusions */
+#pragma hdrstop
+
+#include "Math\Headers\DLMath.H" /* The master file */
+/*-------------------------------------------------------------------------*/
+/* Caution: function is not intended to be cryptographically secure */
+MONSTERLONG64* ml64RandomGenerate(PS_ML64RNDGEN_OPTIONS Poptions, PMONSTERLONG64 Pg) /* Generates a random 64-bit number, returns pointer that was sent to aid expressions */
+{
+  /* locals */
+  static MONSTERLONG64 prevNum; /* Previous number */
+  static BOOL isPrevNumValid; /* Set when prevNum is set */
+  static initByUs; /* We have inited the seed from the time at least once */
+  S_ML64RNDGEN_OPTIONS safeOptions; /* Keeps options safe, even if user didn't specify them */
+  MONSTERLONG64 genInUse; /* Numbering being generated */
+  BOOL bUnacceptable = FALSE; /* Everthing is smooth Chris Richmond */
+
+  memset(&genInUse, 0, sizeof(genInUse)); /* Zero the number to generate */
+
+  if (Poptions) /* Caller specified his options? */
+  {
+    safeOptions = *Poptions; /* Copy them locally */
+  }
+  else /* Caller couldn't be bother to make any options */
+  {
+    /* set defaults */
+    safeOptions.MustDiffer = FALSE; /* Doesn't have to differ */
+    safeOptions.NoZero = FALSE; /* Zero is an acceptable result */
+    safeOptions.InitMode = 1; /* Init if not done before by us */
+  }
+
+  /* Correct bad init mode (init mode is bad if > 2) */
+  if (safeOptions.InitMode > 2) safeOptions.InitMode ^= safeOptions.InitMode;
+
+  if (Pg) /* Caller sent pointer to the number to generate */
+  {
+    /* Decide if to init the generator */
+    if (safeOptions.InitMode) /* Possible init? <-- Gives us a new block to create a new automatic variable set */
+    {
+      /* locals */
+      BYTE initMode = safeOptions.InitMode; /* Copy var to save me some typing! */
+      BOOL doInit = FALSE; /* We know if to do the init by this var */
+
+      if (initMode == 1 /* possible init */ && !initByUs) /* Not done before? */
+        doInit = TRUE; /* Then we will do the init again */
+      if (initMode == 2) /* Definate init */
+        doInit = TRUE; /* Then we will do the init */
+
+      if (doInit) /* Meant to be doing the init */
+      {
+        srand( time(NULL) ); /* Re-seed the generator with the current time */
+        initByUs = TRUE; /* Yes, we have init.ed the generator */
+      }
+    }
+
+    /* Generate the number according to the rules */
+    do
+    {
+      /* This might be a 16-bit prog so make sure we get nice big numbers */
+      genInUse.lo = rand() * rand() * rand(); /* Generate lo-DWORD */
+      genInUse.hi = rand() * rand() * rand(); /* Generate hi-DWORD */
+
+      /* Now for the rules */
+      if (safeOptions.NoZero) /* Zero is not treated as an acceptable random number? */
+      {
+        if (!genInUse.lo && !genInUse.hi) /* Number is zero? */
+          bUnacceptable = TRUE; /* Can't be having this! */
+      }
+
+      if (safeOptions.MustDiffer && isPrevNumValid) /* This number MUST differ from the previous number */
+      {
+        if (prevNum.lo == genInUse.lo && prevNum.hi == genInUse.hi) /* Number matches previous number? */
+          bUnacceptable = TRUE; /* This is unacceptable, you'll have to go around again! */
+      }
+    } while (bUnacceptable); /* Keep looping while number is unacceptable */
+
+    /* Now the generated number must be copied to the caller */
+    *Pg = genInUse; /* Copy number to the caller */
+  } /*(Pg)*/
+
+  return Pg; /* Return the pointer which was sent to us for use in the caller's possible expression */
+}
+/*-------------------------------------------------------------------------*/
+#include "Stds\DLStdInc.H"
+#pragma hdrstop
+
+#include "Math\Headers\DLMath.H"
+
+void ml64Subml64(MONSTERLONG64* PML64, const MONSTERLONG64* Sub64)
+{
+  if (PML64 && Sub64)
+  {
+    if (Sub64->hi || Sub64->lo)
+    {
+      MONSTERLONG64 copyOfSub64 = *Sub64; /* Copy Sub64 to allow modification of copy */
+
+      while (copyOfSub64.hi) /* Hi-DWORD singles left to subtract? */
+      {
+        PML64->hi--; /* Decrement hi-DWORD once */
+        copyOfSub64.hi--; /* Decrement loops to do */
+      }
+      while (copyOfSub64.lo) /* Lo-DWORD singles left to subtract? */
+      {
+        PML64->lo--; /* Decrement lo-DWORD once */
+        copyOfSub64.lo--; /* Decrement loops to do */
+      }
+    }
+  }
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+void ml64AddDWORD(MONSTERLONG64* PML64, const DWORD New32)
+{
+  /* This method is very slow! */
+  if (PML64 && New32)
+  {
+    DWORD i;
+    for (i=0;i<New32;i++) /* For the number of single increments to make */
+    {
+      if (PML64->lo == ~0UL) /* Lo-DWORD reached maximum value? */
+      {
+        PML64->lo ^= PML64->lo; /* Zero the lo-DWORD */
+        PML64->hi++; /* Increment the hi-DWORD */
+      }
+      else /* Lo-word still has room for expansion? */
+      {
+        PML64->lo++; /* Increment the lo-DWORD */
+      }
+    }
+  }
+
+  return;
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+void ml64Addml64(MONSTERLONG64* PML64, const MONSTERLONG64* New64)
+{
+  /* This method is very slow! */
+  if (PML64 && New64)
+  {
+    MONSTERLONG64 Add64 = *New64; /* Copy monster long amount from caller */
+
+    /* Add hi-DWORDs first */
+    while (Add64.hi) /* Hi-DWORDs to do? */
+    {
+      PML64->hi++; /* Increment the hi-DWORD in the QWORD to add to */
+      Add64.hi--; /* Decrement amount to do */
+    }
+    /* Add lo-DWORDs now and have a caution for overruns */
+    while (Add64.lo) /* Lo-DWORDs to do? */
+    {
+      if (PML64->lo == ~0UL) /* Lo-DWORD already max? */
+      {
+        PML64->lo ^= PML64->lo; /* Zero the lo-DWORD */
+        PML64->hi++; /* Increment the hi-DWORD instead */
+      }
+      else /* Lo-DWORD can take more? */
+      {
+        PML64->lo++; /* Increment the lo-DWORD */
+      }
+      Add64.lo--; /* Decrement lo-DWORDs to add */
+    }
+  }
+
+  return;
+}
+#include <Stds\DLStdInc.H>
+#pragma hdrstop
+
+#include "Math\Headers\DLMath.H"
+
+MONSTERLONG64* ml64Compml64(const MONSTERLONG64* PML64_A, const MONSTERLONG64* PML64_B, BOOL* BisGreater)
+{
+  /* locals */
+  static MONSTERLONG64 statRes; /* Static result */
+  const MONSTERLONG64* Pgreater; /* Pointer to greatest value */
+  const MONSTERLONG64* Plesser; /* Pointer to lesser value */
+
+  /* Get equality out of the way */
+  if (PML64_A->lo == PML64_B->lo) /* Lo-DWORDs match? */
+  {
+    if (PML64_A->hi == PML64_B->hi) /* Hi-DWORDs match? */
+    {
+      statRes.lo ^= statRes.lo; /* Zero lo-DWORD */
+      statRes.hi ^= statRes.hi; /* Zero hi-DWORD */
+      return &statRes; /* Give result to caller */
+    }
+  }
+
+  if (PML64_B->hi > PML64_A->hi) /* B's hi-DWORD greater than A's hi-DWORD? */
+  {
+    Pgreater = PML64_B; /* B is greater, set pointer */
+    if (BisGreater) *BisGreater = TRUE; /* Tell caller B is greater */
+  }
+  else if (PML64_B->hi < PML64_A->hi) /* B's hi-DWORD less than A's hi-DWORD? */
+  {
+    Pgreater = PML64_A; /* A is greater, set pointer */
+    if (BisGreater) *BisGreater = FALSE; /* Tell caller A is greater */
+  }
+  else /* Hi-DWORDs match? */
+  {
+    if (PML64_B->lo > PML64_A->lo) /* B is greater */
+    {
+      Pgreater = PML64_B; /* Set pointer */
+      if (BisGreater) *BisGreater = TRUE; /* Tell caller B is greater */
+    }
+    else /* A is greater */
+    {
+      /* Possibility of equality has already been removed */
+      Pgreater = PML64_A; /* Set pointer */
+      if (BisGreater) *BisGreater = FALSE; /* Tell caller A is greater */
+    }
+  }
+
+  /* Now I have a pointer to the greater number.  I should make the pointer
+  to the lesser number too, this will take some logic though */
+  Plesser = (Pgreater == PML64_A) ? (PML64_B) : (PML64_A);
+
+  statRes = *Pgreater; /* Set the greater value as the result temporarily */
+  ml64Subml64(&statRes, Plesser); /* Substract lesser from greater to make difference */
+
+  return &statRes; /* Give result to caller */
+}
+/*-------------------------------------------------------------------------*/
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+#define SIGNBIT ( 2147483648UL ) /* Bit 31 (32nd bit) in hi-DWORD, this calculated by 2 ^ 31 */
+
+BOOL ml64QuerySignBit(const MONSTERLONG64* CPML64)
+{
+  return (
+           ((CPML64->hi & SIGNBIT) == SIGNBIT) 
+  );
+}
+
+void ml64SetSignBit(MONSTERLONG64* PML64, const BOOL SetOrClear)
+{
+  if (SetOrClear) /* Setting sign bit? */
+  {
+    PML64->hi |= SIGNBIT;
+  }
+  else /* Clearing sign bit? */
+  {
+    PML64->hi &= ~SIGNBIT;
+  }
+}
+#include "Stds\DLStdInc.H"
+
+#include "Math\Headers\DLMath.H"
+void ml64SubDWORD(MONSTERLONG64* PML64, const DWORD Sub32)
+{
+  /* This method is very slow! */
+  if (PML64 && Sub32)
+  {
+    DWORD i;
+    for (i=0;i<Sub32;i++) /* For the number of single decrements to make */
+    {
+      if (PML64->lo == 0UL) /* Lo-DWORD reached minimum value? */
+        PML64->hi--; /* Decrement the hi-DWORD */
+
+      PML64->lo--; /* The lo-DWORD is decremented too, nomatter what the case of the hi-DWORD */
+    }
+  }
+
+  return;
+}

CPP/ml64/object.CPP

+#include "Stds\DLStdInc.H" // Daybo Logic standards
+#pragma hdrstop
+
+#include "Math\Headers\DLMath.H"
+
+#ifndef __NO_NAMESPACES__
+using namespace Overlord::DLMath;
+#endif
+//---------------------------------------------------------------------------
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::TMonsterLong64()
+{
+  /* Init 64-bit number */
+  _ml64.lo = 0UL;
+  _ml64.hi = 0UL;
+}
+//---------------------------------------------------------------------------
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::TMonsterLong64(TMonsterLong64& CopyCons)
+{
+  _ml64.lo = CopyCons._ml64.lo;
+  _ml64.hi = CopyCons._ml64.hi;
+}
+//---------------------------------------------------------------------------
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::TMonsterLong64(MONSTERLONG64* PML64)
+{
+  if (PML64)
+  {
+    _ml64.lo = PML64->lo;
+    _ml64.hi = PML64->hi;
+  }
+}
+//---------------------------------------------------------------------------
+TMonsterLong64&
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::operator =(TMonsterLong64& a)
+{
+  _ml64.lo = a._ml64.lo;
+  _ml64.hi = a._ml64.hi;
+  return a; // For expressions (required)
+}
+//---------------------------------------------------------------------------
+TMonsterLong64&
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::operator ==(TMonsterLong64&)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::Addml64(const MONSTERLONG64* New64)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::AddDWORD(const DWORD New32)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::AddWORD(const WORD New16)
+{
+}
+//---------------------------------------------------------------------------
+MONSTERLONG64*
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::RandomGenerate(PS_ML64RNDGEN_OPTIONS Poptions)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::Subml64(const MONSTERLONG64* Sub64)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::SubDWORD(const DWORD Sub32)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::SubWORD(const WORD Sub16)
+{
+}
+//---------------------------------------------------------------------------
+MONSTERLONG64*
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::Compml64(const MONSTERLONG64* PML64_B, BOOL* BisGreater)
+{
+}
+//---------------------------------------------------------------------------
+MONSTERLONG64*
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::CompDWORD(const DWORD DW_B, BOOL* BisGreater)
+{
+}
+//---------------------------------------------------------------------------
+MONSTERLONG64*
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::CompWORD(const WORD W_B, BOOL* BisGreater)
+{
+}
+//---------------------------------------------------------------------------
+BOOL
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::QuerySignBit()
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::SetSignBit(const BOOL SetOrClear)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::MultiplyDWORD(const DWORD New32)
+{
+}
+//---------------------------------------------------------------------------
+void
+#ifndef __NO_NAMESPACES__
+Overlord::DLMath::
+#endif
+TMonsterLong64::MultiplyWORD(const WORD New16)
+{
+}
+//---------------------------------------------------------------------------
+/* Sorry if you're looking for stuff, this is just a redirection */
+
+#include "Math\Headers\DLMath.H"
+#ifndef __INC_DLMATH_H
+/*****************************************
+ * Daybo Logic Mathematics Macro Header, *
+ * (C) Copyright 1998-1999, Daybo Logic. *
+ *                                       *
+ * All rights reserved.                  *
+ *****************************************
+This file contains valuable trade secrets of Daybo Logic.
+DO NOT DISTRIBUTE IS SOURCE CODE FORM OR ANY FORM WHERE IT IS THE
+MAIN PART OF AN APPLICATION & THE PROGRAM DOES NOT SERVE A USEFUL PURPOSE.*/
+/*-------------------------------------------------------------------------*/
+#define __INC_DLMATH_H /* define header */
+/*----- ENTER HEADER MACRO DECLARATIONS BELOW & NOT ABOVE THIS POINT ------*/
+
+/* English weights & measures (weights) */
+#define OZFROMLB(OuncesOut, PoundsIn) \
+	OuncesOut = Pounds * 16;
+#define LBFROMOZ(PoundsOut, OuncesIn) \
+	PoundsOut = Ounces / 16;
+#define STONESFROMLB(StonesOut, PoundsIn) \
+	StonesOut = PoundsIn / 14;
+#define LBFROMSTONES(PoundsOut, StonesIn) \
+	PoundsOut = StonesIn * 14;
+#define STONESFROMCWTS(StonesOut, CWTsIn) \
+	StonesOut = CWTsIn * 8;
+#define CWTSFROMSTONES(CWTsOut, StonesIn) \
+	CWTsOut = StonesIn / 8;
+#define TONSFROMCWTS(TonsOut, CWTsIn) \
+	TonsOut = CWTsIn / 20;
+#define CWTSFROMTONS(CWTsOut, TonsIn) \
+	CWTsOut = TonsIn * 20;
+
+/* English weights & measures (measurement) */
+#define INCHESFROMFEET(InchesOut, FeetIn) \
+	InchesOut = FeetIn * 12;
+#define FEETFROMINCHES(FeetOut, InchesIn) \
+	FeetOut = InchesIn / 12;
+
+/* Computer storage computing */
+#define BYTESFROMPARAGRAPHS(BytesOut, ParagraphsIn) \
+	BytesOut = ParagraphsIn * 16;
+#define PARAGRAPHSFROMBYTES(ParagraphsOut, BytesIn) \
+	ParagraphsOut = BytesIn / 16;
+#define BITSFROMPARAGRAPHS(BitsOut, ParagraphsIn) \
+	BitsOut = (ParagraphsIn * 8) * 16;
+#define PARAGRAPHSFROMBITS(ParagraphsOut, BitsIn) \
+	(BitsIn / 16) / 8;
+#define BYTESFROMKB(BytesOut, KBIn) \
+	BytesOut = KBIn * 1024; /* this value is 1 KB exactly (a power of 2) */
+#define KBFROMBYTES(KBOut, BytesIn) \
+	KBOut = BytesIn / 1024;
+#define BYTESFROMMB(BytesOut, MBIn) \
+	BytesOut = MBIn * 1048576; /* this value is 1 MB exactly (a power of 2) */
+#define MBFROMBYTES(MBOut, BytesIn) \
+	MBOut = BytesIn / 1048576;
+#define GBFROMMB(GBOut, MBIn) \
+	GBOut = MBIn * 1024;
+#define MBFROMGB(MBOut, GBIn) \
+	MBOut = GBIn / 1024;
+
+/*----- ENTER HEADER MACRO DECLARATIONS ABOVE & NOT BELOW THIS POINT ------*/
+
+#ifndef SQUARE
+#	define SQUARE(x) ((x)*(x))
+#endif /*SQUARE*/
+#ifndef CUBE
+#	define CUBE(x) ((x)*(x)*(x))
+#endif /*CUBE*/
+
+#define KILOBYTE (1024)
+#define MEG (SQUARE(KILOBYTE))
+#define GIG (SQUARE(KILOBYTE)* KILOBYTE)
+
+/*----------------- ENTER STRUCTURES BELOW THIS LINE ----------------------*/
+
+/*----- ENTER FUNCTION DECLARATIONS FOR FUNCTIONS DEFINED IN DLMATH.C -----*/
+
+#include "Headers\BeginCH.H" /* C-style naming... */
+
+long lFactorial(short n);
+double dFactorial(double n);
+long double ldFactorial(double n);
+
+#include "Math\Headers\ml64.H" /* For the ml64 functions */
+
+#include "Headers\EndCH.H" /* End C-style naming */
+
+/*----- NO MORE FUNCTION DECLARATIONS BELOW THIS POINT --------------------*/
+/*------ENTER HEADERS BELOW THIS POINT ------------------------------------*/
+
+#include "Math\Headers\Pow.H" /* Power maths */
+
+/*-------------------------------------------------------------------------*/
+#endif /* __INC_DLMATH_H end of header file */
+#ifndef __INC_MATH_POW_H
+#define __INC_MATH_POW_H
+#include "Headers\BeginCH.H"
+/*-------------------------------------------------------------------------*/
+unsigned int powi(unsigned int x, unsigned int y);            /* powi.c */
+unsigned short powsi(unsigned short x, unsigned short y);     /* powsi.c */
+unsigned long powli(unsigned long x, unsigned long y);        /* powli.h */
+/*-------------------------------------------------------------------------*/
+#include "Headers\EndCH.H"
+#endif /*__INC_MATH_POW_H*/
+#ifndef __INC_MATH_ML64_ML64_H
+#define __INC_MATH_ML64_ML64_H
+/*-------------------------------------------------------------------*/
+#include "Math\Headers\ml64Type.H"
+#include "Headers\BeginCH.H"
+
+#define ML64_VERSION (0x0010) /* Version number xx.xx (V0.1) */
+
+void ml64Addml64(MONSTERLONG64* PML64, const MONSTERLONG64* New64); /* Adds a monster long 64-bit number to a longer long64-bit number */
+void ml64AddDWORD(MONSTERLONG64* PML64, const DWORD New32); /* Adds a 32-bit number to a monster long 64-bit number */
+#define ml64AddWORD(p, v) ml64AddDWORD((p), (DWORD)(v)) /* Adds a 16-bit number to a monster long 64-bit number */
+
+MONSTERLONG64* ml64RandomGenerate(PS_ML64RNDGEN_OPTIONS Poptions, PMONSTERLONG64 Pg); /* Generates a random 64-bit number following rules sent in the options, the structure for which was declared earlier in this file */
+
+void ml64Subml64(MONSTERLONG64* PML64, const MONSTERLONG64* Sub64); /* Subtracts a 64-bit monster long from another 64-bit monster long */
+void ml64SubDWORD(MONSTERLONG64* PML64, const DWORD Sub32); /* Subtracts a 32-bit number from a monster long 64-bit number */
+#define ml64SubWORD(p, v) ml64AddDWORD((p), (DWORD)(v)) /* Subtracts a 16-bit from a monster long 64-bit number */
+
+MONSTERLONG64* ml64Compml64(const MONSTERLONG64* PML64_A, const MONSTERLONG64* PML64_B, BOOL* BisGreater); /* Compares to monster long 64-bit values and returns the difference (0 if they match).  The return is a static number which is overwritten with every call, it is reconmended that the caller make a copy straight away */
+MONSTERLONG64* ml64CompDWORD(const MONSTERLONG64* PML64_A, const DWORD DW_B, BOOL* BisGreater); /* Compares a monster long 64-bit to a DWORD and returns the difference (0 if they match).  The return is a static number which is overwritten with every call, it is reconmended that the caller make a copy straight away.  When result <> 0 the BisGreater flag (if caller wants it) is set TRUE if B was greater or FALSE if A was greater */
+#define ml64CompWORD(p, wv, b) ml64CompDWORD((p), (DWORD)(wv), (b)) /* Same as above but for WORD */
+
+BOOL ml64QuerySignBit(const MONSTERLONG64* CPML64);
+void ml64SetSignBit(MONSTERLONG64* PML64, const BOOL SetOrClear);
+
+void ml64MultiplyDWORD(MONSTERLONG64* PML64, const DWORD New32);
+#define ml64MultiplyWORD(p, wv) ml64MultiplyDWORD((p), (DWORD)(wv))
+
+
+
+/* This is a C class which conforms to Overlord David Duncan Ross Palmer's
+CClass paper which is available internally to Daybo Logic and Area 27
+Digital Solutions.  It encapsulates a 64-bit monster long type with's
+it's functions as members. */
+
+typedef struct _S_MONSTERLONG64 /* Object version */
+{
+  /* All members are public, however, pointers to function must not be modified from outside! */
+  void (*Addml64)(void*, const MONSTERLONG64* New64);
+  void (*AddDWORD)(void*, const DWORD New32);
+  void (*AddWORD)(void*, const WORD New16);
+
+  MONSTERLONG64* (*RandomGenerate)(void*, PS_ML64RNDGEN_OPTIONS Poptions);
+
+  void (*Subml64)(void*, const MONSTERLONG64* Sub64);
+  void (*SubDWORD)(void*, const DWORD Sub32);
+  void (*SubWORD)(void*, const WORD Sub16);
+
+  MONSTERLONG64* (*Compml64)(void*, const MONSTERLONG64* PML64_B, BOOL* BisGreater);
+  MONSTERLONG64* (*CompDWORD)(void*, const DWORD DW_B, BOOL* BisGreater);
+  MONSTERLONG64* (*CompWORD)(void*, const WORD DW_B, BOOL* BisGreater);
+
+  BOOL (*QuerySignBit)(void*);
+  void (*SetSignBit)(void*, const BOOL SetOrClear);
+
+  void (*MultiplyDWORD)(void*, const DWORD New32);
+  void (*MultiplyWORD)(void*, const WORD New16);
+
+  /* DATA */
+  MONSTERLONG64 _ml64;
+} S_MONSTERLONG64, *PS_MONSTERLONG64;
+
+/* Since the 'structors have to be outside of the object, here they are: */
+void S_MONSTERLONG64_Construct(PS_MONSTERLONG64 PObject); /* Object constructor */
+void S_MONSTERLONG64_ConstructAndInit(PS_MONSTERLONG64 PObject, MONSTERLONG64* InitVal); /* Object constructor setting an initial value */
+/* There is no destructor, internal destruction of the object is not required anyway, since the object never allocates memory dynamically */
+
+
+/* The following class is valid only in C++ mode . . . */
+#ifdef __cplusplus
+
+#ifndef __NO_NAMESPACES__ /* Allowed to use namespaces? */
+namespace Overlord { /* The latest base namespace for Overlord DDRP */
+  namespace DLMath { /* The Daybo Logic math namespace */
+#endif /*!__NO_NAMESPACES__*/
+
+    class TMonsterLong64
+    {
+    public:
+      TMonsterLong64(); // Default constructor
+      TMonsterLong64(TMonsterLong64& CopyCons); // Copy constructor
+      TMonsterLong64(MONSTERLONG64* PML64); // Init constructor
+      TMonsterLong64& operator =(TMonsterLong64&);
+      TMonsterLong64& operator ==(TMonsterLong64&);
+      void Addml64(const MONSTERLONG64* New64);
+      void AddDWORD(const DWORD New32);
+      void AddWORD(const WORD New16);
+      MONSTERLONG64* RandomGenerate(PS_ML64RNDGEN_OPTIONS Poptions);
+      void Subml64(const MONSTERLONG64* Sub64);
+      void SubDWORD(const DWORD Sub32);
+      void SubWORD(const WORD Sub16);
+      MONSTERLONG64* Compml64(const MONSTERLONG64* PML64_B, BOOL* BisGreater);
+      MONSTERLONG64* CompDWORD(const DWORD DW_B, BOOL* BisGreater);
+      MONSTERLONG64* CompWORD(const WORD W_B, BOOL* BisGreater);
+      BOOL QuerySignBit();
+      void SetSignBit(const BOOL SetOrClear);
+      void MultiplyDWORD(const DWORD New32);
+      void MultiplyWORD(const WORD New16);
+
+        MONSTERLONG64 _ml64;
+    }; //TMonsterLong64
+
+#ifndef __NO_NAMESPACES__ /* Allowed to use namespaces? */
+  }; /* end namespace DLMath */
+}; /* end namespace Overlord */
+#endif /*!__NO_NAMESPACES__*/
+
+#endif /*__cplusplus*/
+
+#include "Headers\EndCH.H"
+/*-------------------------------------------------------------------*/
+#endif /*!__INC_MATH_ML64_ML64_H*/

Headers/ml64Type.H

+#ifndef __INC_MATH_ML64_TYPE_H
+#define __INC_MATH_ML64_TYPE_H
+/*-------------------------------------------------------------------*/
+/*
+  Thme ml64 (MONSTERLONG64) type was created by Overlord David Duncan
+  Ross Palmer of Daybo Logic in late 1999 AD to resolve the langauge
+  problem in ANSI C (1990) which did not allow for an explicit 64-bit
+  type.  In 1999 there was a need to use 64-bit number but a reluctance
+  to use 64-bit processors or use language that supported 64-bit numbers.
+  Especially by died-in-the-wool ANSI C programmer's like me.  Therefore
+  I created the ml64 library to make sure I could use 64-bit numbers
+  without breaking ANSI regulations, hell it would even work on 16-bit
+  processors since it just used DWORDs with extra logic.
+  The scheme uses normal binary arithmatic and the most significant
+  bit is the sign bit, functions for querying and settings the sign bit
+  are available.
+*/
+/*-------------------------------------------------------------------*/
+typedef struct _MONSTERLONG64
+{
+  DWORD hi;
+  DWORD lo;
+} MONSTERLONG64, *PMONSTERLONG64;
+
+typedef struct _S_ML64RNDGEN_OPTIONS /* Options for a call to ml64RandomGenerate */
+{
+  BOOL MustDiffer; /* This number must not be the same as the previous one */
+  BOOL NoZero; /* If zero is generated the generator starts again until result is nonzero */
+  /* Init of random number generator (with time) */
+  BYTE InitMode; /* 0=no init, 1-init if not done before by this function, 2=Force init, anything else is 0 */
+} S_ML64RNDGEN_OPTIONS, *PS_ML64RNDGEN_OPTIONS;
+/*-------------------------------------------------------------------*/
+#endif /*!__INC_MATH_ML64_TYPE_H*/

Binary file added.

+/* Sorry if you're looking for maths stuff read Headers\DLMath.H, this is just a
+direction */
+
+#include "Math\DLMath.H"

Binary file added.

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.