# float « decimal « Java Data Type Q&A

### 1. How to get the decimal part of a float?    stackoverflow.com

I need to extract the decimal part of a float number, but I get weird results:

``````float n = 22.65f;
// I want x = 0.65f, but...

x = n % 1; // x ...``````

### 2. iReport java.lang.Float hide decimals if zero    stackoverflow.com

From IBM iSeries DB2 I recieve a ordered quantity DEC 11,4. In iReport I use java.lang.Float to print the value. Also I have a pattern #,##0.0000;-#,##0.0000 (4 Decmimal places, 1000 separator). When something ...

### 3. decimal part of a float    coderanch.com

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - ...

### 4. Float decimal points..    coderanch.com

just a word of caution... it's generally rather risky to represent currency with a float. you generally want to store it as an int, and (for US), have it hold pennies. for display purposes, you can then convert it. i can't tell from you're post if you're doing this or not. and for a small (possibly homework assignment), it probably doesn't ...

### 5. Help decimal number { float or double??} HELP!    java-forums.org

Please if u could run the program, and when asked please use 1 for lower limit and 3 for upper limit, and finally 46 for n. I have assigned deltaX = ( ( upperLimit - lowerLimit) / subInt ) and then multiplied it by 1/3, which is the value of numb which does not give me a decimal number, same goes ...

### 6. How to tell if a float number actually has decimal values    forums.oracle.com

So what happens when I need to show the value with decimal places? The values that are entered can be 1.00, 3.43. 2.00 etc. I need to show the values without decimal values as 1, 2 etc and the others as is. How can I use the same variable to represent both?

### 8. program terminates when the input number is in decimals(floating number)    forums.oracle.com

/** * This is for measuring the account after depositing the money in * account 2 */ System.out .println("Please enter the amount you want to deposit in account2 :"); depositAmount = input.nextDouble(); System.out.printf("adding %.2f to account2 balance", depositAmount); account2.credit(depositAmount); System.out.printf("Account1 balance:\$%.2f\n", account1.getBalance()); System.out.printf("Account2 balance :\$%.2f\n", account2.getBalance()); /** * This is to measuring the amount withdraw from account2 */ System.out .println("Please enter ...