What does it means?

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

    What does it means?

    I'm new on C# and I would like to know what it means and
    if it is necessary.

    decimal[] balances = new decimal[12];

    decimal ttl = 0m;

    What does 0m, means is necessary for the programman
    that "m", what does it means????????

    Thanks for all

    Arthur
  • Yura2000

    #2
    RE: What does it means?

    Without m number will be treated as double, with m - as decimal.

    Comment

    • Jim

      #3
      What does it means?

      Arthur,

      In C++, which I'll assume you're familiar with, we can put
      little modifiers after constants to identify the data type
      of the constant (because the integer 0 and the floating
      point number 0.0, while numerically equivalent, are stored
      different in memory, again as I'm sure you already know).
      Most languages have their own ways of representing these.
      In C++, you refer to floating point constants with the
      prefix f, like "float f = 0.0f", and long integers
      like "long l = 2L". Visual BASIC uses modifers too, like
      the % sign for integers, the & for long integers, the #
      sign for double-precision floats, and the ! for single-
      precision... I think that's right anyway.. a logn time
      since I used VB....

      Anyway, now that I've covered the erlavant background, the
      answer to your question is that the "m" modifier
      identifies the constant 0 as a "decimal" value, to match
      the data type of the variable. I'm new to C# too, so if I
      got that wrong, anyone feel free to chime in. :) I hope
      that helps!

      JIM[color=blue]
      >-----Original Message-----
      >I'm new on C# and I would like to know what it means and
      >if it is necessary.
      >
      >decimal[] balances = new decimal[12];
      >
      >decimal ttl = 0m;
      >
      >What does 0m, means is necessary for the programman
      >that "m", what does it means????????
      >
      >Thanks for all
      >
      >Arthur
      >.
      >[/color]

      Comment

      • Jon Skeet [C# MVP]

        #4
        Re: What does it means?

        ArtPedUK <anonymous@disc ussions.microso ft.com> wrote:[color=blue]
        > I'm new on C# and I would like to know what it means and
        > if it is necessary.
        >
        > decimal[] balances = new decimal[12];
        >
        > decimal ttl = 0m;
        >
        > What does 0m, means is necessary for the programman
        > that "m", what does it means????????[/color]

        "m" shows that the literal should be interpreted as a decimal as
        opposed to an integer.

        --
        Jon Skeet - <skeet@pobox.co m>
        Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

        If replying to the group, please do not mail me too

        Comment

        Working...