absolute value of a integer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Henry

    absolute value of a integer

    Is there a way to get an absoulte value of a 32bit signed integer? I noticed
    Math.abs is an 8-bit integer, but i need the absoulte value of a larger
    number. thanks!


  • Nick Malik [Microsoft]

    #2
    Re: absolute value of a integer

    The math.abs function is overloaded. You can pass in any of the following
    types and a number OF THAT TYPE is returned
    long
    short
    single
    double
    sbyte
    integer
    decimal

    Overloading allows the compiler to chose the correct function based upon the
    type of the value passed in.

    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster


    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
    "Brian Henry" <nospam@nospam. com> wrote in message
    news:%23aLJeZL% 23EHA.2568@TK2M SFTNGP10.phx.gb l...[color=blue]
    > Is there a way to get an absoulte value of a 32bit signed integer? I[/color]
    noticed[color=blue]
    > Math.abs is an 8-bit integer, but i need the absoulte value of a larger
    > number. thanks!
    >
    >[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: absolute value of a integer

      "Brian Henry" <nospam@nospam. com> schrieb:[color=blue]
      > Is there a way to get an absoulte value of a 32bit signed integer? I
      > noticed Math.abs is an 8-bit integer, but i need the absoulte value of a
      > larger number.[/color]

      'Math.Abs' is overloaded, and there is one overload that takes an 'Int32'
      and returns an 'Int32'.

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

      Comment

      • Brian Henry

        #4
        Re: absolute value of a integer

        thanks didin't notice that... was relying on intellisense too much for what
        it returned and forgot about overloading


        "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
        news:eB%23vplL% 23EHA.1188@tk2m sftngp13.phx.gb l...[color=blue]
        > "Brian Henry" <nospam@nospam. com> schrieb:[color=green]
        >> Is there a way to get an absoulte value of a 32bit signed integer? I
        >> noticed Math.abs is an 8-bit integer, but i need the absoulte value of a
        >> larger number.[/color]
        >
        > 'Math.Abs' is overloaded, and there is one overload that takes an 'Int32'
        > and returns an 'Int32'.
        >
        > --
        > M S Herfried K. Wagner
        > M V P <URL:http://dotnet.mvps.org/>
        > V B <URL:http://dotnet.mvps.org/dotnet/faqs/>[/color]


        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: absolute value of a integer

          "Brian Henry" <nospam@nospam. com> schrieb:[color=blue]
          > thanks didin't notice that... was relying on intellisense too much for
          > what it returned and forgot about overloading[/color]

          If you are using VS.NET, there is a small arrow shown in the intellisense
          tooltip if overloads exist. You can use the up and down keys to switch
          between the overloaded versions.

          --
          M S Herfried K. Wagner
          M V P <URL:http://dotnet.mvps.org/>
          V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

          Comment

          Working...