data type for decimal number

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

  • Richard Heathfield
    Guest replied
    Re: data type for decimal number

    Keith Thompson said:
    Richard Heathfield <rjh@see.sig.in validwrites:
    >vhanwaribrahim@ gmail.com said:
    >>
    ><snip>
    >>
    >>Some times the when you print addresses using %d it will show as
    >>negative,
    >>
    >Don't print addresses using %d. Addresses are pointer values, so use %p.
    >
    Use %p *after* converting the value to void*.
    Whoops, I forgot to mention that.

    <snip>
    >Actually, %x takes an int, not a hex. C doesn't have a hex type.
    >
    Actually, %x takes an unsigned int.
    4.9.6.1 of C89:

    d, i, o, u, x, X The int argument is converted to signed decimal ( d
    or i ), unsigned octal ( o ), unsigned decimal ( u ), or unsigned
    hexadecimal notation ( x or X );

    Sure looks like int to me.

    <snip>

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Leave a comment:


  • Mark Bluemel
    Guest replied
    Re: data type for decimal number

    Keith Thompson wrote:
    ... unsigned long is very
    often the same size as unsigned long, but it's not guaranteed.
    Is this the Schroedinger C compiler we're talking about here?

    Leave a comment:


  • vhanwaribrahim@gmail.com
    Guest replied
    Re: data type for decimal number

    On Feb 16, 11:40 pm, neha_chha...@ya hoo.co.in wrote:
    which is the best format specifier(data type) if i have to work with
    decimal number.
    >
    The best format specifier for a decimal number depends upon how you
    want
    to use it. If you want to display a normal signed integer , you can
    use "%d"
    unsigned integer "%u".

    Some times the when you print addresses using %d it will show as
    negative,
    but we know that addresses cant be negative. So we should use %u as
    format
    specifier.


    As you know numbers can be signed or unsigned and the value
    it can hold depends upon the type we use it. Also if you want
    large values, you have to use appropriate data types and correspoding
    format specifiers according to that. for eg.

    int - %d
    long - %ld
    double - %lf
    float - %f
    hex -%x.


    for the rest you can refer this link








    also please tell me the syntax for truncating a decimal number
    >
    if you mean to say display after truncating a decimal number,
    then you can use the format specifiers used for float.


    please reply as soon as possible











    Leave a comment:


  • Antoninus Twink
    Guest replied
    Re: data type for decimal number

    On 18 Feb 2008 at 3:22, Kenny McCormack wrote:
    In article <ROCdnX1flqRUfC XanZ2dneKdnZydn Z2d@bt.com>,
    Richard Heathfield <rjh@see.sig.in validwrote:
    >>Robert W Hand said:
    >>
    >>On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
    >><rjh@see.sig. invalidwrote:
    >>>
    >>>>There is no such thing as a "decimal number". Numbers are numbers. But
    >>>>presumabl y you mean that you wish to display a number using decimal
    >>>>notation, and your reference to a format specifier suggests that you wish
    >>>>to do this using printf.
    >>>
    >>A tiny point. The Standard does use the term "decimal number" in the
    >>section on strftime(). Its meaning is exactly what you wrote about
    >>display, but I would avoid writing that there is no such thing as ....
    >>You know that there is always an exception. ;-)
    >>
    >>The fact that the Standard uses the term "decimal number" does not mean
    >>there is such a thing as a decimal number. It merely means that the people
    >>who wrote that part of the Standard think there is such a thing as a
    >>decimal number.
    >
    I will leave it to my esteemed colleague, Mr. Twink, to give this post
    all the respect that it deserves.
    It would be nice to say something funny and cutting, but Heathfield's
    post is so far off into la-la land that it's beyond the power of parody
    to match the absurdity of the post itself... Still, it must be fun in a
    way to be Heathfield, completely unconstrained by reality.

    Leave a comment:


  • Kenny McCormack
    Guest replied
    Re: data type for decimal number

    In article <ROCdnX1flqRUfC XanZ2dneKdnZydn Z2d@bt.com>,
    Richard Heathfield <rjh@see.sig.in validwrote:
    >Robert W Hand said:
    >
    >On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
    ><rjh@see.sig.i nvalidwrote:
    >>
    >>>There is no such thing as a "decimal number". Numbers are numbers. But
    >>>presumably you mean that you wish to display a number using decimal
    >>>notation, and your reference to a format specifier suggests that you wish
    >>>to do this using printf.
    >>
    >A tiny point. The Standard does use the term "decimal number" in the
    >section on strftime(). Its meaning is exactly what you wrote about
    >display, but I would avoid writing that there is no such thing as ....
    >You know that there is always an exception. ;-)
    >
    >The fact that the Standard uses the term "decimal number" does not mean
    >there is such a thing as a decimal number. It merely means that the people
    >who wrote that part of the Standard think there is such a thing as a
    >decimal number.
    I will leave it to my esteemed colleague, Mr. Twink, to give this post
    all the respect that it deserves.

    Leave a comment:


  • Richard Heathfield
    Guest replied
    Re: data type for decimal number

    Robert W Hand said:
    On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
    <rjh@see.sig.in validwrote:
    >
    >>There is no such thing as a "decimal number". Numbers are numbers. But
    >>presumably you mean that you wish to display a number using decimal
    >>notation, and your reference to a format specifier suggests that you wish
    >>to do this using printf.
    >
    A tiny point. The Standard does use the term "decimal number" in the
    section on strftime(). Its meaning is exactly what you wrote about
    display, but I would avoid writing that there is no such thing as ....
    You know that there is always an exception. ;-)
    The fact that the Standard uses the term "decimal number" does not mean
    there is such a thing as a decimal number. It merely means that the people
    who wrote that part of the Standard think there is such a thing as a
    decimal number.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Leave a comment:


  • Robert W Hand
    Guest replied
    Re: data type for decimal number

    On Sat, 16 Feb 2008 18:50:57 +0000, Richard Heathfield
    <rjh@see.sig.in validwrote:
    >There is no such thing as a "decimal number". Numbers are numbers. But
    >presumably you mean that you wish to display a number using decimal
    >notation, and your reference to a format specifier suggests that you wish
    >to do this using printf.
    A tiny point. The Standard does use the term "decimal number" in the
    section on strftime(). Its meaning is exactly what you wrote about
    display, but I would avoid writing that there is no such thing as ....
    You know that there is always an exception. ;-)

    Leave a comment:


  • Richard Heathfield
    Guest replied
    Re: data type for decimal number

    neha_chhatre@ya hoo.co.in said:
    which is the best format specifier(data type) if i have to work with
    decimal number.
    There is no such thing as a "decimal number". Numbers are numbers. But
    presumably you mean that you wish to display a number using decimal
    notation, and your reference to a format specifier suggests that you wish
    to do this using printf.

    If you have an int type, use %d or %i. For short int and long int, apply
    the appropriate modifiers, as listed in your C book (in K&R2 they're on
    page 244). For unsigned int types, use %u rather than %d or %i.

    If you wish to display a floating point type, use %f.
    also please tell me the syntax for truncating a decimal number
    This depends on what you mean by "truncate" and on what type of value you
    wish to truncate (and particularly on whether you want the stored value to
    be truncated, or merely the displayed value).

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Leave a comment:


  • neha_chhatre@yahoo.co.in
    Guest started a topic data type for decimal number

    data type for decimal number

    which is the best format specifier(data type) if i have to work with
    decimal number.

    also please tell me the syntax for truncating a decimal number

    please reply as soon as possible
Working...