Math.Ceiling, how to cast the value, proper synthax?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Greenwood
    New Member
    • Sep 2010
    • 7

    Math.Ceiling, how to cast the value, proper synthax?

    Hi Im trying to Math.Ceiling with the following code, where fr is a array of doubles and max is an int, it give me the following error "Error The call is ambiguous between the following methods or properties: 'System.Math.Ce iling(decimal)' and 'System.Math.Ce iling(double)'"

    Code:
    for (int i = 0; i < fr.Length; i++)
                {
                    if (fr[i] < max)
                    {
                        max = (int)Math.Ceiling(i);
                    }
                }
    Please advise Thanks
  • Anton Zinchenko
    New Member
    • Sep 2010
    • 16

    #2
    Maybe you made a typo?
    Code:
                for (int i = 0; i < fr.Length; i++)
                {
                    if (fr[i] < max)
                    {
                        max = (int)Math.Ceiling([B]fr[i][/B]);
                    }
                }
    If it's not a typo, than you can cast i to double and it should work (max = (int)Math.Ceili ng((double)i);)
    Last edited by Anton Zinchenko; Sep 20 '10, 06:36 PM. Reason: additional comment

    Comment

    Working...