1. Lightweight Java Decimal Class stackoverflow.comI am considering writing two limited precision alternatives to BigDecimal, namely DecimalInt and DecimalLong. These would be capable of dealing with numbers within the real bounds of int and long ... 
2. truncating number after decimal...through built in function in java stackoverflow.comi want to truncate a number after decimal through a built in function in *java* (not javascript). for example: 69.80000000001 to 69.8 please guide. 
3. find decimal in a given number stackoverflow.comHow can i find decimal(dot) in a given number in java. I am getting input from user, he may give integer or float value. I need to find he entered integer or ... 
4. Function to calculate with decimals in Java stackoverflow.comThis code is works fine when you type 22 and 56 for example, it shows you the correct result

5. Fixed decimal numbers with JAVA stackoverflow.comHow do I represent numbers in the format
The number of digits is always ... 
6. logic for checking sequential order in decimal numbers using java stackoverflow.comI want to check the sequential order of decimal numbers and find the missing number. For eg: If i have 1.1.1, 1.1.3, 1.1.4, 2.1.1, 2.1.3, 2.1.2, 3, etc Here i need to find ... 
7. Best Java Object for Incredibly Small Decimals stackoverflow.comWhat java object is best suited to hold tiny decimal values, such as 10^25? What object will maintain the value of the number most accurately, while using the least space? I simply ... 
8. Unexpected decimal result stackoverflow.comI run the following code, but did not expect that result..

9. Storing large decimal numbers in JAva stackoverflow.comI need to store 17774132 in a double format, but it seems that double is to small since I get 1.7774132E7. How can I overcome this problem? I need some kind of ... 
10. wrong java decimal and therefore wrong calculation stackoverflow.comThe output I got is like this:
that correct total cost should be 224.67 because 236.50  11.83 = 224.67
the ... 
11. Assign variables to numbers left of decimal and right bytes.com 
12. BCD to decimal and viceversa coderanch.comHi, Am working on conversion of decimal to BCD (Binary coded decimal) and viceversa. I require BCD for calling Cobol from Java using JNI. Can anybody help me out in giving a pointer or an algorithm for doing the same. I Googled on the web for any info on BCD conversion, but all in vain. Please help me out. TIA, Prashanth ... 
13. a simple addition of decimal numbers coderanch.comIn our project, we are taking care that all the float numbers shuld be of two decimal places only and we r not using something like BigDecimal for this to keep it simple. So, at all the divisions I am taking care of rounding it to two decimals. Now I found a strange test case, where in adding two numbers with ... 
14. java decimal multiplication coderanch.com 
15. Validating a decimal number coderanch.comHi, My requirement is to validate a decimal number. I have the information about the maximum integer digits and maximum allowed digits in the fraction part. What can be the best way to do it? I am unable to use DecimalFormat... Is there any way i can make use of set the interger and fraction part using setMaximumIntegerDigits and setMaximumFractionDigits of ... 
16. Decimal Convertion coderanch.comHi I need to print the Double Value with 2 decimal digits. i am getting the double value like 1.07142858E7,but actually i need to show the value like this 10714285.8(this is the converted value) Can any one suggest me that how can i print the converted value. (1.07142858E7 as 10714285.8) Thank you Naresh 
17. Finding recurring cycle in a decimal. coderanch.comWhat I can tell you however is that a recurring fraction a/b will recur in less than b places. Hmm.. didn't know that, thanks. Isn't it also true that a rational number will either be a terminating or a recurring decimal? that is, it will never be both nonterminating and nonrecurring?? If so, using BigDecimal with an appropriate scale, ... 
18. Aline decimals coderanch.com 
19. Obtaining only a decimal portion of a number. coderanch.comIt's been quite a while since I used JAVA, I'm finishing undeprecating alot of the code I wrote years ago (Can it be that long?) I need a method that will only return the decimal portion of a number (i.e. fx(123.456) would return .456) but I can't find a built in method to do so. I know other languages have this ... 
20. how to subtract decimal???? coderanch.comhi guys!!! i had a program that subtract two double variable.here's my code: import java.awt.*; import java.awt.event.*; public class Try { public static void main(String argv[]) { Frame fr = new Frame(); fr.pack(); fr.setVisible(true); Panel panel = new Panel(); final TextField tf1 = new TextField(15); final TextField tf2 = new TextField(15); final Button subtract = new Button("Minus"); Button clear = new ... 
21. Octals, Decimals and Hexadecimals coderanch.comI think that he means by hand. Octal uses a ones place, and 8's place, a 64's place, 512 etc. Basically you just need to find out how many of each that you need. To convert 489 decimal to octal 512's = 0 too big 64's = 7 divide 489 by 64 = 7 remainder 41 8's = 5 divide 41 ... 
22. displaying decimal numbers coderanch.com 
23. Changing decimal to octale (and etc.) coderanch.com 
24. Decimal Alignment coderanch.com 
25. Decimal Powers.. simple question coderanch.comMixedtype arithmetic is tricky. Doing math with some integers and some doubles means that some of your partial results ( that "aNote/440", for example) are going to be done in integer math, which of course truncates fractional parts. The quickest fix here would be to use doubles for all the constants: public double getFrequency(int midiNote) { double aNote = 440; return ... 
26. Binary/Octal/Hex and Decimal Number Systems coderanch.comthe different number systems simply refers to how many digits you can use. humans use 10 digits... 09. to count, we start cycling through them all. when we run out, we start using two digits at a time. when we run out of every possible 2digit combination, we go to three. so a number like 243 really means 2*10^2 + 4*10^1 ... 
27. what will it be 0x1f400000L if converted to decimal coderanch.com 
28. getting the right decimal... coderanch.comI have been working with an online class and have this project to complete. I have everything working, Except the deicmals.. (ie. if I have $478.00 I only get $478.0 printed). What do I do to get the other zero?.. Below I have attached my code incase I've over looked something.. class payRoll { public static void main (String [] args) ... 
29. data type for large decimals coderanch.com 
30. Decimal Subtraction coderanch.comI am trying to subtract decimal numbers but I'm not getting the desired results. For instance when I subtract 12 from 12.92 I should get 0.92 instead I the answer is 0.9199999999999999999. What can I do to get 0.92? If I round it off I'll get 1 which is not the answer i want. Your help will be highly appreciated. 
31. decimal part coderanch.com 
32. adding decimal numbers coderanch.comFernando Dominguez wrote:Hello, I'm trying to add to Doble numbers with 2 decimal places, 12,25 + 23, 46 = 35, 71 I get most of the time. But some times, for example, 12,10 + 20,15 gets 32,24999999999999999999996 Why? Thanks in advance I'm a student engineer, no java expert at all but I can tell you a bit about numerical math: A ... 
33. Decimals in Java coderanch.comI have a variable which was defined as a double(primitive data type).Now this variable is supposed to store 8 digits or more with decimals.For ex.778906211.35.But this is stored in an exponential formatexample 7.7890621135E8.How do I store it so that the entire format is shownie as 778906211.35.Should I use the BigDecimal Class? Please advise. Thanks Richard 
34. Getting rid of unwanted decimal numbers coderanch.comThe problem asks for me to list side by side how many pounds are in a kilogram from 1 to 199. I have everything right except all these random zeros pop up after each of the pounds. For example, 3 kilograms = 6.600000000000005 pounds. I have read on this else where, and everyone suggests using the decimal format, DecimalFormat("#,###.##"); , but ... 
35. How to get rid of unwanted decimal numbers coderanch.comThe problem asks me to list numbers from 10,000 to 100,000 on the left side and the PI value for every 10,000. Everything is correct except for all of the decimal numbers that pop up. for example, 10000 multiplied by PI is 3.1415.8999999998. I have read on this else where, and everyone suggests using the decimal format, DecimalFormat("#,###.##"); , but unfortuantely ... 
36. Decimals in java help!! javaforums.orghi i need some help with java ive got an assignment and 1 of the questions is 22 divided by 1000000 see i no the answer is 0.000022 but everytime i try it in bluej i keep gettin the answer as 0.0 ive tried float and double could anyone suggest another way for me to get my answer showing correctly thank ... 
37. Store the decimal number into an variable javaforums.org 
38. Decimal Fill up javaforums.orgHey guys Below mentioned is a simple program which i wrote that will decide how many digits to display after decimal place. class Exercise1 { public static void main(String[] args) { double d = 2344.5; System.out.println("%.5f", d); } } Now as per the above code the output should be 2344.500000, but instead of that i get an error cannot find symbol, ... 
39. truncate a decimal number ? javaforums.orgI have a double variable, value of it is 0.8251913258676211, But I want to display only 0.82 . And Later than I am going to use this 0.82 for arithmetic expression so I can not do toString(). Is there anyway to do this and how?. I am not trying to round my number; I got my number as a result of ... 
40. Trying to store a decimal between 0&1 after dividing by 100 javaforums.orgHi, I'm not totally new to Java, been playing for a while but I've hit an embarassing brick wall. The answer to this must be simple but I just can't get it!!! Basically I'm playing with making a little text based game. Each enemy has an amount of damage it can do, and I'm trying to make it relate to it's ... 
41. using decimal numbers javaforums.orgFirst off, I did search a bit. But being new and not really understanding much I'm not quite sure how to word things to get the answer I want. What I was able to find confused me more. But I did find a trend in answers, to which I'm sure someone will elude to. 
42. decimal limit help javaforums.org 
43. Got an error when enter the number in decimal eg 30.23 javaforums.orgI am at the very initial stage of learning Java.I wrote basic program called account.Program is working fine when I enter the number without decimal eg.34,64....But it gives the following error when I enter the nuber with decimal eg.34.87,54.65 ************************************************** ******** account1 balance:$50,00 account2 balance:$0,00 Please enter the amount you want to deposit in account1 : 45.63 Exception in thread "main" ... 
44. Quick question about numbers and decimals javaforums.org 
45. Beginner trying to write Java code, has issue w/ printing result and 2 decimals javaforums.orgI'm taking a Java class which I am really liking so far. So I have this problem I am working on now. A. Create a class name purchase. Each purchase. Contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set() method for the sale amount, calculate ... 
46. Payroll program will not print decimals... could someone help? javaforums.orgimport java.util.Scanner; public class Payroll2 { public static void main( String[] args ){ Scanner input = new Scanner( System.in ); { System.out.print ( "Enter employee name: " ); String theName = input.nextLine(); { } int hours; { System.out.println("Enter hours worked:"); String line = input.nextLine(); hours = Integer.parseInt(line); if(hours < 0) System.out.println("number must be positive"); } while(hours < 0); int pay; do ... 
47. Java does not read the decimals? javaforums.orgHello. I was going to post this on the Appleta' site, as it's a problem from an applet, but as I overloaded it with threads today and I think it's a general Java problem, I decided to post it here. Well, the thing is that I've got a varyable named "x", and I set it at 1. Summarizing it all, t ... 
48. Need help with truncating decimals? javaforums.orgimport java.util.Scanner; public class Args{ public static void main(String[] args) { Scanner in = new Scanner(System.in); double iBalance; int month=0; int year=0; int finalBalance; System.out.println ("Enter your Initial Balance."); iBalance=in.nextInt(); in.close(); System.out.println("Balance is:\n"+iBalance); while (iBalance > 500) { iBalance = iBalance*(1.005)500; month++; } while (month>=12) { year = month/12; month = month12; } if (year > 0) { System.out.println (+year+" years ... 
49. Help with decimals javaforums.orgHi I am trying to write a program which works out a bunch of stuff, and I want the final answer to be given to 2 decimal places Here is an excerpt from the code, the bit which I need to be given to 2 decimal places is the last two lines. I used 2 classes, om is a copy of ... 
50. Getting/changing the decimal symbol? javaforums.orgI have a string containing a decimal number. But if I convert it to a float or double, the decimal symbol will either be be ignored or the method throw a NumberFormatException (I'm not sure which one) if the program is run on a machine with a different decimal symbol specified in the settings than what is used in the string, ... 
51. parseInt with decimals forums.oracle.comI'm in the second week of my Java class, so try to keep it simple for me! I'm trying to change the decimal entry someone inputted into my program by entry = Integer.parseInt(response); obviously, this doesnt work because it changes the decimal to a whole number... which I can't have for this specific program. What would be the command I would ... 
52. Help: "no exact representable decimal result" forums.oracle.com 
53. Getting rid of decimals forums.oracle.com 
54. Adding decimals  help! forums.oracle.comCan Java add 10.2 + 0.1 and output the 10.3? I tried all sorts of things, and I can't figure out how! Here is one test: double d = 10.2; double delta = 0.1; double c = d + delta; System.out.println(c); The output is 10.299999999999999 It is really important that I get an exact result, because I need to increment numbers ... 
55. How to decide number of decimals forums.oracle.com 
56. Newbie Needs help with decimals forums.oracle.comclass ArrayTest { public static void main( String [] args) { double[] anArray1; double[] anArray2; anArray1 = new double[3]; anArray2 = new double[3]; anArray1[0] = 7; // product number anArray1[1] = 25; // amount in stock anArray1[2] = 75.99; // price per unit anArray2[0] = 13; // product number anArray2[1] = 12; // amount in stock anArray2[2] = 59.99; // price ... 
57. Help with project: trying to create variables from decimals forums.oracle.comtopic may be a bit unclear, but I have a project from a java course. I need to create a simple program, but hit a bit of a bump. I have made a formula to find that the total hours equals 2.7350 which is equal to 2hours, 44minutes, 6seconds. so to sum what I just said up, I have the number ... 
58. how to convet a decimal number of in to base 64. forums.oracle.com 
59. need help with decimals forums.oracle.comnot the greatest of examples, but thx for the references here's what i need help with public class pro24{ public static void main(String args[]) throws java.io.IOException { int days = 180; double dist = 2.5; //in miles: going one way int mpg = 26; // miles per gallon double gpg; //cost of gas per gallon System.out.println("How much does gas cost per ... 
60. Quick question about decimals forums.oracle.com 
61. How do I display only 2 decimals ? forums.oracle.com 
62. decide the number o decimal houses in a decimal number forums.oracle.com 
63. Please check out this : Roman to decimal forums.oracle.comDecimal/Roman Conversion Roman numerals consist of the letters I, V, X, L, C, D, M which represent the values 1, 5, 10, 50, 100, 500, 1000. These letters are combined in an ordervalue system. Basically the rule is, if a letter is followed by an equal or lower valued one it counts as positive. If it is followed by a higher ... 
64. Calculating pi.. decimals? forums.oracle.com/*Calculation the value of pi: Calculate the value of pi from the infinite series pi=44/3+4/54/7+4/94/11... Print in a table that shows the value of pi approximated by computing the first 200.000 terms of this series. How many terms do you have to use before you first get a value that begins with 3.14159? */ 
65. Bug in decimal calculations forums.oracle.com 
66. About decimal number! forums.oracle.com 
67. decimal formatter help forums.oracle.com 
68. Decimal problem (while calculating PI) forums.oracle.comHere's an explanation of why your algorithm does not work: Imagine a (pizza) pie; if you cut it in two, you'll have two halves of it. You leave one alone and cut the other; again you have two halves. You can keep doing that for a long time and you'll always have something left to split in two, but it will ... 
69. Recurring Decimal forums.oracle.comOK, 2 things here: 1  I don't see anyplace that you actually set a decimal point. 2  to my knowlege you cannot add an int to an ArrayListwhen I try to do it, I've always gotten an error. Possibly there is an implicit conversion from int to your Integer type, if that is so, then see comment 1. 
70. RowFilter Not working for decimals forums.oracle.comThe problem is not with parsing of String. Number filter takes Number object (in this case Double) and uses it's equals method, which actually compares internal double value. That value is stored as a binary fraction. Not every decimal fraction can be exactly mapped to a finite binary fraction much less to one that fits completely into double's 64 bits. Thus ... 
71. please up decimals? forums.oracle.commjohnsonaz74 wrote: Never use a Double or a Float for price information. You lose precision. Always use a BigDecimal for prices. For currency, the BigDouble.toString() should be sufficient. Or you could use a number formatter for finer control. Yes, use BigDecimal if you want your code to be unreadable. A better solution is to use ints or longs and store your ... 
72. decimal part of a number forums.oracle.com 
73. how to convet a decimal number of in to base 64. forums.oracle.com 
74. dertermine if an excel cell contains a decimal  apache poi forums.oracle.comWhat's simple about it? If it's a number cell it just contains a number. And a number doesn't "have a .0", it's just a number. Perhaps you're asking about the formatting of the cell? That displays the number to the Excel user as a string. If that's the case, then get the string value of the cell or something like that. ... 
75. Coverting Decimal code to Char(For Html Chartacter) forums.oracle.com 
76. equivalent for decimal type forums.oracle.comThe binary representation of a Decimal value consists of a 1bit sign, a 96bit integer number, and a scaling factor used to divide the 96bit integer and specify what portion of it is a decimal fraction. The scaling factor is implicitly the number 10, raised to an exponent ranging from 0 to 28. 
77. Decimals in Calculator Code forums.oracle.comAre you asking for 10 / 2 display 5 but for 9 / 2 display 4.5? If so then you can use the mod operator. If x % y == 0 then do integer division otherwise do floating point division. Or there maybe some other uber mathematical way to do it that only math wiz's like Jos know about. 
78. IBM Mainframe Decimal Converion forums.oracle.com 
79. char to decimal forums.oracle.com 
80. Packed Decimal Data validation forums.oracle.comHi, For legacy system..we are getting Date and time in packed decimal format.I wanted to put validation for time . Time should be an integer value.. But whatever may be value of time (String alphabet or int),while converting from packed decimal to long,its doing successfully. but i wanted to put an check ,and allow only integer value. PackedDecimalConverter converter = new ... 
81. Problems with decimal. forums.oracle.comThanks again for responding. Fully understand the issue of monetary values. I happen to BigDecimal to avoid going crazy. It will be a tedious job because all the software is developed with float and never could tell because he had problems with decimals. But I am happy to find the problem and know how to solve it. Thank you very much. ... 