Detecting integer or float in user input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prashantdwivedi
    New Member
    • Feb 2008
    • 1

    Detecting integer or float in user input

    i want to write a program that display data type of enterd value that enter by user.E.G. if user enter 2 then our program will display it is an integer value,if user enter 10.5 then our program will display it is an float value.user can enter only one value at a time.thanks
  • Meetee
    Recognized Expert Contributor
    • Dec 2006
    • 928

    #2
    Hi,

    What you both need to do is kindly read posting guidelines of this forum. Please be specific about your problem and also attach your efforts on the same so far.

    Regards

    Comment

    • Simonius
      New Member
      • Feb 2008
      • 47

      #3
      And it seems quite impossible to me.
      How are you going to tell if it's a double or a float?
      A long or an int?

      What you can do is make a program that tells you the smallest datatype that you can use for it.

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        prashantdwivedi , I was in 2 minds about deleting this thread and the only reason I have not is that you have written
        Originally posted by prashantdwivedi
        i want to write a program ...
        we are not going to write your program for you but since you want to write it yourself you should go ahead and try, you can post back here with your attempt and the problems you are having.

        Simonius reply seems to be to be a fairly good summation of the situation, you are going to have to work out what characterises these different number formats and devise a way to detect those different characteristics .

        A simple place to start might be what characterises a number as a float rather than an integer?

        Comment

        Working...