mql4-lib icon indicating copy to clipboard operation
mql4-lib copied to clipboard

Json.mqh 的 parseInt 是否該做以下修正?

Open OmarHung opened this issue 3 years ago • 0 comments

Mql\Format\Json.mqh

bool     parseInt(int &sign,int &value)
     {
      sign=1;
      unichar c=m_stream.nextChar();
      if(c=='-')
        {
         sign=-1;
         c=m_stream.nextChar();
        }
      value=0;
      if(c=='0') // 0
        {
         // sign=1; // 上面預設就是sign=1這裡還做sign=1會把負數變為正
         return true;
        }
      else if(c<='9' && c>='1') // onenine 0..9
        {
         do
           {
            value*=10;
            value+=(int)(c-'0');
            c=m_stream.nextChar();
           }
         while(c<='9' && c>='0');
         m_stream.pushChar(c);
         return true;
        }
      else
        {
         return false;
        }
     }

OmarHung avatar Oct 16 '21 04:10 OmarHung