BigNumberByLeo/Src/Base/Def.mqh

100 lines
3.7 KiB
MQL5
Raw Permalink Normal View History

2026-08-17 12:21:57 -05:00
//+------------------------------------------------------------------+
//| Def.mqh |
//| Copyright 2026, Niquel Mendoza |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, Niquel Mendoza"
#property link "https://www.mql5.com"
#property strict
#ifndef BIGNUMBERSBYLEO_SRC_BASE_DEF_MQH
#define BIGNUMBERSBYLEO_SRC_BASE_DEF_MQH
2026-08-17 17:30:57 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include <TSN\\Tables\\DPairs.mqh>
2026-08-21 21:01:14 -05:00
#include <TSN\\Tables\\Bits.mqh>
2026-08-25 19:48:27 -05:00
#include <TSN\\Tables\\Swar.mqh>
2026-08-17 17:30:57 -05:00
2026-08-17 12:21:57 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
namespace TSN
{
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
// inter
// a b = A
// c d = B
// (ad) (bd)
// (cb)
// (ac)
// inter es como el intermdio serian dos sumas sin carray y le sumas el carray que dejo
// inter = (ad)(cb) + carry
// lo = inter (solo tomoamos el valor raw no el carray) | (juntamos con lo)
#define BIGNUMBERSBYLEO_MUL64(b, hi, lo) \
{\
const ulong b_lo = (uint)b;\
const ulong b_hi = b >> 32;\
const ulong lo_lo = a_lo * b_lo;\
const ulong hi_lo = a_hi * b_lo;\
const ulong lo_hi = a_lo * b_hi;\
const ulong hi_hi = a_hi * b_hi;\
const ulong inter = (lo_lo >> 32) + (uint)hi_lo + (uint)lo_hi;\
lo = (inter << 32) | (uint)lo_lo;\
hi = hi_hi + (hi_lo >> 32) + (lo_hi >> 32) + (inter >> 32);\
}
2026-08-17 22:34:56 -05:00
//-------
// cualquier funcion que pueda producirr 0
#define BIGNUMBERSBYLEO_CLEAN_HIGH_ZEROS \
{ \
while(m_v_s > 0 && m_v[m_v_s - 1] == 0) \
m_v_s--; \
}
2026-08-17 12:21:57 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
// Menos de 30 limbs finales (Entonces se usa school)
#define BIGNUMBERBYLEO_MUL_SCHOL_TO_KARATSUBA (16)
// Apartir en mas adlente se usa mas..
2026-08-22 14:12:43 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#define BIGINTEGERBYLEO_ALLOC_V \
ulong v[];\
ArrayResize(v, vs);\
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
// numero de digitos maximo sin desopborar ulong que podiramso acomular por cada base en un chunk de clecutra de uns tr
const int g_tsn_biguinteger_base_max[11]
{
-1, // 0
-1, // 1
64, // 2
40,
32,
27,
24,
22,
21,
20,
19
};
2026-08-23 17:38:27 -05:00
//+------------------------------------------------------------------+
//| BigUInteger::ToBytes* |
//+------------------------------------------------------------------+
#define BIGUINTEGER_TOBYTES_DEFAULTK (-1)
2026-08-23 19:37:22 -05:00
#define BIGUINTEGER_LOADBYTES_BE (1)
#define BIGUINTEGER_LOADBYTES_LE (-1)
2026-08-17 12:21:57 -05:00
}
//+------------------------------------------------------------------+
2026-08-17 22:34:56 -05:00
#endif // BIGNUMBERSBYLEO_SRC_BASE_DEF_MQH