70 lines
2.8 KiB
MQL5
70 lines
2.8 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| U.mq5 |
| |||
//| Copyright 2026, Niquel Mendoza. |
| |||
//| https://www.mql5.com |
| |||
//+------------------------------------------------------------------+
| |||
#property copyright "Copyright 2026, Niquel Mendoza."
| |||
#property link "https://www.mql5.com"
| |||
#property version "1.00"
| |||
#property strict
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
#include "..\\Conv.mqh"
| |||
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
void Test(const string s)
| |||
{
| |||
ulong v = 0;
| |||
int pos = 0;
| |||
TSN::CStringConvert::ToValueNUnsigned(s, pos, v, StringLen(s));
| |||
PrintFormat("%-26s -> %I64u (pos=%d)", s, v, pos);
| |||
}
| |||
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| |
| |||
//+------------------------------------------------------------------+
| |||
void TestI(const string s)
| |||
{
| |||
int v = 0;
| |||
int pos = 0;
| |||
TSN::CStringConvert::ToValueNSigned(s, pos, v, StringLen(s));
| |||
PrintFormat("%-26s -> %d (pos=%d)", s, v, pos);
| |||
}
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Script program start function |
| |||
//+------------------------------------------------------------------+
| |||
void OnStart()
| |||
{
| |||
//---
| |||
Print("----------");
| |||
TestI("2147483647");
| |||
TestI("2147483648");
| |||
TestI("-2999999999");
| |||
| |||
//---
| |||
Print("----------");
| |||
Test("0");
| |||
Test("000000000000000000255"); // ceros a la izquierda → 255
| |||
Test("9223372036854775807"); // LONG_MAX (19 díg.)
| |||
Test("9223372036854775808"); // LONG_MAX+1 (19 díg.)
| |||
Test("18446744073709551614"); // ULONG_MAX-1
| |||
Test("18446744073709551615"); // ULONG_MAX ← el tuyo
| |||
Test("184467440737095516150"); // ULONG_MAX+1 → debe saturar
| |||
Test("19999999999999999999"); // tu wrap-around → debe saturar
| |||
Test("99999999999999999999"); // 20 nueves → debe saturar
| |||
Test("123456789012345678901234;asa"); // 24 díg. → debe saturar
| |||
Test("255;otra"); // pos debe quedar en 3
| |||
Test("abc"); // sin dígitos → v=0
| |||
Test("x5"); // un carácter inválido delante
| |||
Test("xx5"); // dos → ¿v=0?
| |||
Test("5abc"); // pos=1
| |||
Test(" 12"); // espacios delante
| |||
}
| |||
//+------------------------------------------------------------------+
|