You ought not to use double for money in the first place. In MySQL you would use the DECIMAL datatype; you will have to check the types returned, but I think that would come out as a BigDecimal. There are remainder and IEEERemainder methods in BigDecimal; you want the ordinary one.
I am sorry if I am not asking the right questions.
Here I will try to better.
What the problem is I am accessing a Sql database and grabbing data Then running it through some if and else stmts.
When I get a transaction that has a 1.00 or 100.00 I want to write out a different type of transaction
When the amt is 1.30 or 100.20 I want to write out a different trx.
I am using a number formatter that gives me a 8 digit double field that place zeros in front of the amount so the field is a total of 8 characters with no commas or periods which it must be to write out my transactions.
I just want to be able to say anything greater than 00000000 in positions 7 and 8 please write this transaction. If positions 7 and 8 equal to zero write a different transaction out. I hope you understand what I am trying to do. If not please let me know and I will try to explain better. Thank you for trying to help me. Justin
Positions 7 and 8? You still haven't said what type of data you are getting from the database. Is it a string or a number? If so what kind of number is it? I'm talking about the type of the Java variable to which you are assigning this value.
Originally posted by Campbell Ritchie: You said integer, but your code says getDouble().
Or it says getString(). The getDouble() calls aren't assigned to any variable so there isn't any question of formatting those double values. I still think we need a coherent question with an example of some code that isn't doing something right, and explanations of what it's doing and what it would be nice for it to do instead.
Right now there's no question on the table here, just hand-waving.
This is what I wanted to do. This works and does exactly what I wanted. When Steve said Modulus I looked at it. Didn't make sense. Then a friend mentioned Modulus again so I looked at it a second time and came up with this. My fried said it is just simple math and I didn't look at it that way.