Coder Social home page Coder Social logo

Comments (3)

dingmaotu avatar dingmaotu commented on June 16, 2024

我想这里不需要改,因为这里判断的是首个或者第二个字符即是0的情况,也就是“-0”,或者“0”,那么就直接返回。这里假设十进制整数的第一个数字不能为0(因为这通常用于表达8进制)

from mql4-lib.

OmarHung avatar OmarHung commented on June 16, 2024

但若數據為負數,最後會變成正數,例如 -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了

from mql4-lib.

dingmaotu avatar dingmaotu commented on June 16, 2024

我看了一下代码,这个 parseInt 并不是独立的,是用在 parseNumber 中的,因此确实是有问题的。多谢~

from mql4-lib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.