11,932,103 members (53,442 online)

Email

Password

Sign in using

Hi there,

I have a whole number counting up and I would like to put a decimal in it to make it look like a US Dollar amount counting up. so the number 59 would be .59 and the number 259 would be 2.59.

I tried using the decimal method like this (00.##) but that just adds to 0's on the end of the number like this, 59 would be 59.00.

Any help would be awesome!

Thank you

I have a whole number counting up and I would like to put a decimal in it to make it look like a US Dollar amount counting up. so the number 59 would be .59 and the number 259 would be 2.59.

I tried using the decimal method like this (00.##) but that just adds to 0's on the end of the number like this, 59 would be 59.00.

Any help would be awesome!

Thank you

Justin Jones359

Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100

float pump1time = Math.abs(timerTextP1 / 100);

timerTextP1Pump1.setText(pump1time + "");

and it looks like its trying to work but it shows 0.0 till the count up equals 1 then it shows 1.0.

it won't show the decimal as it counts up. Weird.

like if it is 25678 then it should be 256.78 or 25.678

25678 would be 256.78

thank you

private int timerTextP1;

private int dollars = timerTextP1 / 100;

private int cents = timerTextP1 % 100;

System.out.format("timerTextP1 = %d.%d", dollars, cents);

timerTextP1Pump1.setText(timerTextP1 + "");

am I doing that right? it just displays the number normal

`timerTextP1`

field. It's no good using`System.out.format`

as that just writes to the console. I am not sure what the actual method would be in Android code.