//+------------------------------------------------------------------+ //| 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 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include #include #include //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ 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);\ } //------- // 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--; \ } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // Menos de 30 limbs finales (Entonces se usa school) #define BIGNUMBERBYLEO_MUL_SCHOL_TO_KARATSUBA (16) // Apartir en mas adlente se usa mas.. //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #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 }; //+------------------------------------------------------------------+ //| BigUInteger::ToBytes* | //+------------------------------------------------------------------+ #define BIGUINTEGER_TOBYTES_DEFAULTK (-1) #define BIGUINTEGER_LOADBYTES_BE (1) #define BIGUINTEGER_LOADBYTES_LE (-1) } //+------------------------------------------------------------------+ #endif // BIGNUMBERSBYLEO_SRC_BASE_DEF_MQH