We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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; } }
The text was updated successfully, but these errors were encountered:
我想这里不需要改,因为这里判断的是首个或者第二个字符即是0的情况,也就是“-0”,或者“0”,那么就直接返回。这里假设十进制整数的第一个数字不能为0(因为这通常用于表达8进制)
Sorry, something went wrong.
但若數據為負數,最後會變成正數,例如 -0.6 會變成 0.6。 下面這邊先標記為負數了,並取下一個字元
if(c=='-') { sign=-1; c=m_stream.nextChar(); }
以-0.6為例的話,會進入上面if內,標記為負數,並取下一個字元0 然後繼續走到
if(c=='0') // 0 { sign=1; // 這裡做sign=1會把負數變為正 return true; }
進入if後 sign=1 又把它改回正數了, 然後退出parseInt這個方法, 走到parseNumber最下面的
value=sign*(intValue+fracValue)*MathPow(10,expValue);
-0.6 就變成 0.6了
我看了一下代码,这个 parseInt 并不是独立的,是用在 parseNumber 中的,因此确实是有问题的。多谢~
cc80979
dingmaotu
No branches or pull requests
Mql\Format\Json.mqh
The text was updated successfully, but these errors were encountered: