• 12-09-2002
boontune
Hi there!

can anyone help me or point me in the right direction,

i am trying to code a calculator that will except floating point numbers upto 6 digits, including the decimal point...

would i need a string to check each of the numbers to make sure the dont go over 6 digit limit??

• 12-09-2002
master5001
Well both the scanf functions and cin have support for doing precision. But you could preprocess a string if you really wanted to.

Alittle help please as a title is bad form, btw. Many people disreguard questions with this title.
[/edit]
• 12-09-2002
master2000
all i know is use double for floating point #

like this:

void main()
{
double n1, n2, n3
}
then just program them in.

try something like

if(n1 = > 6)

hope it helps
• 12-09-2002
Pioneer
You need to use a string to read the number, then convert it to a double when you've checked it for length.
• 12-09-2002
master2000
A little help please isn't a good name i suggest some random marks like this \$&^%\$%(&%\$^#\$\$^&*%(^%^(&%
• 12-09-2002
PJYelton
Keep multiplying the number * 10 until there is no decimal point
Code:

```while(int(num)!=num) {   num*=10; }```
Then if this number divided by one million is less than zero then the original is 6 digits or less else it isn't.

PS. I *think* this works but I haven't tested it! :D
• 12-09-2002
Hammer
Yes, we all know the thread title isn't the best choice, hopefully boontune will choose more wisely next time.

@master2000
void main() is wrong, please don't promote its use.
And please do not make further posts like this one:
Quote:

A little help please isn't a good name i suggest some random marks like this \$&^%\$%(&%\$^#\$\$^&*%(^%^(&%
I suggest you read the forum guidelines. Any questions, PM me.
• 12-10-2002
boontune
Thanks alot for your help guys,

Cheers again!
• 12-10-2002
master2000
Quote:

Originally posted by Hammer
Yes, we all know the thread title isn't the best choice, hopefully boontune will choose more wisely next time.

@master2000
void main() is wrong, please don't promote its use.
And please do not make further posts like this one:

I suggest you read the forum guidelines. Any questions, PM me.

sorry

also i always use void main()
• 12-10-2002
master2000
Quote:

Originally posted by boontune
Thanks alot for your help guys,

Cheers again!

• 12-10-2002
master5001
I usually use float main().
• 12-10-2002
master2000
what do you use it for?:confused:
• 12-10-2002