# decimal « decimal « C Data Type Q&A

Home
C Data Type Q&A
 1 binary 2 bit 3 byte 4 char 5 character 6 decimal 7 Development 8 float 9 hex 10 integer 11 prime 12 random 13 struct
 C Data Type Q&A » decimal » decimal

### 1. atoi and leading 0's for decimal numbers    stackoverflow.com

When using atoi in C I am trying to convert a char array of numbers to an int. I have leading 0's on my number though and as the C compiler ...

### 2. Which c datatype should be use for decimal numbers?    stackoverflow.com

I need to use a field of type numeric(11,9) in mysql. I'm using C api so which data type I should use. I used long so it gives result like these:

...

### 3. data type for decimal number    bytes.com

neha_chhatre@yahoo.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 ...

### 4. Write all numbers with 3 decimals?    bytes.com

I have a program that writes something like this: 0 0 -1 0 -0.6 0.8 0 0 0.8 0 0 0 0 0 0 1 I write that with this statement: std::cout << m[i][j] << " "; in a loop. Is there some way to print all numbers with 3 decimals including the potential minus, so I get something like this: ...

### 5. how to find if a number contains a decimal    bytes.com

no..i'm doing some math calculations and need to ..i think.. convert the results to a string or char so i can determine if there is a decimal point int the math result..maybe it can be done someway else??? If u are doing a math calculation then why ar u converting it to string. If u think the math expression may give ...

### 6. Problem in the convertion of any number base B to decimal    bytes.com

Hi, the program is asking the user for a number ant he base of the number, then it will convert the number to decimal. But is running right only with base 2, 3, 4, 5, 6, 7, 8 but if I try 16 it is not working. can some one help me please. Thanks #include #include using namespace std; ...

### 10. Help! Can't read decimal number    cboard.cprogramming.com

Hi, I've written the following program, and somehow b'cos of the compiler i'm using. it won't read in a decimal number. The below file is my fprint.h file , which 'allows' me to read in floats -------------------------------------------------------------------------------- void Fprint(double,int); void Fprint(double num,int dec) { double num2,num3; long j,y,z,i; y=(long)num; if (dec>0){ i=dec; dec=1; while (i>0){ dec=dec*10; i--; } num2=(double)y; num3=(num-num2)*dec; z=(long)num3; ...

### 12. Checking to see whether or not a var contains a whole number or a decimal    forums.devshed.com

Is there a function I can use tht does this? Basically I want the following if statement: if(isNotAwholeNumber) { // Do nothing and continue in a while loop } else { // If it is a whole number break; // Frm the while loop } I am using Dev C++, and coding in C++. Thanks.

### 14. Adding decimal numbers together?    daniweb.com

short amount (float n) { short a = 0, i, totvalue = 0; for (i = 0; i < sizeof (n); i++) { a = n = (n * 10); n -= a; totvalue += a; } return totvalue; } int main() { double a = 0.1234; cout<<"Value = " << amount(a) <