Announcement

Collapse
No announcement yet.

Rounding

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rounding

    Hello. I have been trying to make this code round my output to the nearest tenth of a digit for the Russel 2000 e-mini. I.e. - 78118 would be 781.20 or 78120. Any ideas? Thanks...


    //==rnd will round to N digits.
    function rnd(value, N) {
    var n;
    var mult=1;
    for(n=0;n<N;n++) mult*=100;
    value*=mult;
    return Math.round( value,N)/mult;
    }

  • #2
    Hi jones,


    Try this...

    PHP Code:
    //==rnd will round to N digits.
    function rnd(valueN) {
        
    N=Number('1e'+N);
        return 
    Math.round(value*N)/N;

    Comment


    • #3
      rounding...

      Steve:

      Thanks for the quick reply. I tried that but it didn't work either. Gave me the same result. Russell e-mini prices still showed up as 81132 instead of 81130...Is there any other way to do this?

      Thanks

      Comment


      • #4
        Hi Jones,

        Your welcome, sorry I missed the point. There is nothing in efs that will change the digit formatting of the chart that I am aware of. (if this is what you want)

        I did a quick check using the search tool in the forum and found this link which may be of some help

        http://forum.esignalcentral.com/show...t%2A#post97479

        A function to simply divide the number such that it is this format in your code is as follows

        PHP Code:
        //==div will divide to N digits.
        function div(valueN) {
            
        N=Number('1e'+N);
            return 
        value/N;

        If you are trying to round the last digit of the number for your code, simply modify the rnd function I posted to reverse the order of multiplying and dividing.
        Last edited by ; 09-14-2007, 11:19 AM.

        Comment


        • #5
          Try this,

          I also use the AB #F and just simply use Math.round....
          after it rounds, then divide by ten outside the ()

          Math.round(B2*10)/10

          hope that helps

          Comment

          Working...
          X