Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Math.Round error

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

    Math.Round error

    Hi,

    I am trying to round to the nearest whole number 90 % of the count of a list but get the error;

    "The call is ambiguous between the following methods or properties: 'System.Math.Round(double, int)' and 'System.Math.Round(decimal, int)'"
    and this

    Cannot implicitly convert type 'double' to 'int'. An explicit conversion exists (are you missing a cast?)

    This is my code;

    Code:
    y = Math.Round(myList.Count * 90/100,0);
    Last edited by GKonheiser; 10-23-2014, 08:50 AM.

    #2
    GKonheiser,

    Thank you for your note.

    You need to specifically cast the double or decimal type in this instance.

    (double)(myList.Count * 90/100)

    Use the above in your Math.Round() to get the value of myList.Count * 90/100 specifically as a double
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      im obviously not getting it, i tried,

      Math.Round(decimal)(list.count * 90/100)

      and a few other variations but its not liking it, what am i doing wrong, I want to round to the nearest whole number?

      Comment


        #4
        GKonheiser,

        You still need the () for the Math.Round method, that has not and will not change.

        Math.Round((double)(myList.Count * 90/100), 0);
        Cal H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        566 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 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
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X