# How to read an input value that is a decimal

Page 1 of 1

## 3 Replies - 939 Views - Last Post: 21 September 2010 - 03:04 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=191341&amp;s=ad056206fa2a85c32eadfc4611ec1810&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ahbrahim2

Reputation: 0
• Posts: 58
• Joined: 21-September 09

# How to read an input value that is a decimal

Posted 21 September 2010 - 12:29 PM

I'm trying to calculate a area. and whant to read an ipnut for the radius from the user, but it has to bee only two decimal place. How can I know the input is two or more decimla. and if the user enter an number that is more than two decimal it has throw and error and reprompt the user to enter again but it does have to be exeption handling.
Thanks for nay help.

This post has been edited by ahbrahim2: 21 September 2010 - 12:31 PM

Is This A Good Question/Topic? 0

## Replies To: How to read an input value that is a decimal

### #2 Salem_c

• void main'ers are DOOMED

Reputation: 2143
• Posts: 4,208
• Joined: 30-May 10

## Re: How to read an input value that is a decimal

Posted 21 September 2010 - 01:13 PM

- read it as a string
- make sure the decimal point is in the right place
- and convert.

### #3 Manipulate

Reputation: 7
• Posts: 38
• Joined: 21-July 10

## Re: How to read an input value that is a decimal

Posted 21 September 2010 - 01:56 PM

What he said. Just put that inside a verification loop and you should be golden.

### #4 ahbrahim2

Reputation: 0
• Posts: 58
• Joined: 21-September 09

## Re: How to read an input value that is a decimal

Posted 21 September 2010 - 03:04 PM

Manipulate, on 21 September 2010 - 12:56 PM, said:

What he said. Just put that inside a verification loop and you should be golden.