Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting Int to Double

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

    Converting Int to Double

    Hi there

    Just wondering why the following does not complile?

    I attempt to convert the Integer, "barsAgo", into a double, in order that i can create a fraction from it, which is then rounded up.

    double holder=0;
    for (int barsAgo = 1; barsAgo <= 10; barsAgo++)

    { holder=barsAgo;
    if (Low[Math.Round(holder/5,0)] < low_price || low_price == 0)
    {low_price= Low[Math.Round(holder/5,0)] ;}
    }

    Any pointers greatly appreciated...

    Tks
    Ben Heaton

    #2
    Math.Round(holder/5,0) return a double which you need to cast to an int like "(int) Math.Round(holder/5,0)".

    Also: clicking on the error message on the error window always brings you to the erroneous code line and provides you an idea what's going wrong.

    Comment


      #3
      Excellent - Tks for that - BH

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X