How can I pad a double with both trailing zeros (two places, for money) and leading spaces before the $ to align the decimal places?
I want my list to look like:
$###.##
$###.##
_$##.##
__$#.##
__$0.##
__$0.00
As the value decreases. The underscores should be spaces, of course. I wasn't sure if they would appear or be deleted in the post.
Also, I changed a function somewhere and a series of print functions decided to start tabbing every fucking word so they're all spread out and I can't find anything wrong with the code. Any ideas?
System.out.print("\n\nWhat would you like to do?\n1. Calculate the Monthly Payment for a fixed rate, fixed term loan.\n");
System.out.print("2. Calculate the number of Months to pay off a loan with a fixed monthly payment.\n");
System.out.print("\nPlease enter the number of your selection: ");
Name:
Anonymous2013-02-03 4:45
Okay, that's new. Maybe when I generated a CSD it changed the spacing.
The number of digits occupied by the whole part of the number will be the floor of the log based 10 of the number. You could calculate that, print the spaces, and then print the number, or you could first print the number to a buffer and remember how many chars were printed.
Stop using java is inferior. use the return value from snprintf.
Name:
Anonymous2013-02-03 4:55
I wish I could stop using Java.
Using logs sounds like a messy pile of shit and I would have to make special cases for when the ones place is zero, the whole number is zero, etc.
>>4
The java way of doing the second method in >>3 would be to create your formatted string for the decimal with two mantissa digits, and then see how long that string is, and determine how many spaces you need that way.
Name:
Anonymous2013-02-03 5:04
I'm having a hard time visualizing exactly how to implement that. If you have the time, would you mind throwing together a function that accomplishes that with an unformatted double as the argument?
If you're needing older than Java 1.5 compatbility (not unusual for enterprise stuff), then you'll need to go find the printf replacement somewhere else.
Name:
Anonymous2013-02-03 10:19
check my implementation of stored doubles
Name:
Anonymous2013-02-03 10:27
இரட்டையர் சேமிக்கப்படும்? என்று மிகவும் நீங்கள் செய்த ஒரு பொழுதுபோக்கு அறிக்கை தான்.
`7MMF' `7MF' .d' "" `7MM db `7MM
MM M dM` MM MM
MM M ,pP"Ybd .gP"Ya mMMmm`7MM `7MM ,p6"bo MM ,MP'`7MM `7MMpMMMb. .P"Ybmmm MM ,pW"Wq. ,pW"Wq.`7MMpdMAo. ,pP"Ybd
MM M 8I `" ,M' Yb MM MM MM 6M' OO MM ;Y MM MM MM :MI I8 MM 6W' `Wb 6W' `Wb MM `Wb 8I `"
MM M `YMMMa. 8M"""""" MM MM MM 8M MM;Mm MM MM MM WmmmP" MM 8M M8 8M M8 MM M8 `YMMMa.
YM. ,M L. I8 YM. , MM MM MM YM. , MM `Mb. MM MM MM 8M MM YA. ,A9 YA. ,A9 MM ,AP L. I8
`bmmmmd"' M9mmmP' `Mbmmd' .JMML. `Mbod"YML.YMbmd'.JMML. YA..JMML..JMML JMML.YMMMMMb .JMML.`Ybmd9' `Ybmd9' MMbmmd' M9mmmP'
6' dP MM
Ybmmmd' .JMML.
,,
mm db mm
MM MM
mmMMmm ,pW"Wq. `7MMpdMAo.`7Mb,od8 `7MM `7MMpMMMb.mmMMmm ,pP"Ybd `7MMpdMAo. ,6"Yb. ,p6"bo .gP"Ya ,pP"Ybd
MM 6W' `Wb MM `Wb MM' "' MM MM MM MM 8I `" MM `Wb 8) MM 6M' OO ,M' Yb 8I `"
MM 8M M8 MM M8 MM MM MM MM MM `YMMMa. MM M8 ,pm9MM 8M 8M"""""" `YMMMa.
MM YA. ,A9 MM ,AP MM MM MM MM MM L. I8 MM ,AP 8M MM YM. , YM. , L. I8
`Mbmo`Ybmd9' MMbmmd' .JMML. .JMML..JMML JMML.`Mbmo M9mmmP' MMbmmd' `Moo9^Yo.YMbmd' `Mbmmd' M9mmmP'
MM MM
.JMML. .JMML.
Name:
Anonymous2013-02-03 19:11
>>19
Use fucking [m] / [aa] to format text art you African Ameritsk nigger
Name:
Anonymous2013-02-03 19:12
`7MMF' `7MMF'`7MMF' `7MF'.M"""bgd MMP""MM""YMM `7MM"""Yb. `7MMF'`7MM"""Yb. `7MM"""Yp, `7MMF'MMP""MM""YMM .g8"""bgd `7MMF' `7MMF'
MM MM MM M ,MI "Y P' MM `7 MM `Yb. MM MM `Yb. MM Yb MM P' MM `7 .dP' `M MM MM
MM MM MM M `MMb. MM MM `Mb MM MM `Mb MM dP MM MM dM' ` MM MM
MM MM MM M `YMMNq. MM MM MM MM MM MM MM"""bg. MM MM MM MMmmmmmmMM
MM MM MM M . `MM MM MM ,MP MM MM ,MP MM `Y MM MM MM. MM MM
MM (O) MM YM. ,M Mb dM MM MM ,dP' MM MM ,dP' MM ,9 MM MM `Mb. ,' MM MM
.JMML. Ymmm9 `bmmmmd"' P"Ybmmd" .JMML. .JMMmmmdP' .JMML..JMMmmmdP' .JMMmmmd9 .JMML. .JMML. `"bmmmd' .JMML. .JMML.
Name:
Anonymous2013-02-03 19:14
,, ,, ,, mmmmm mmmmm
`7MM db mm `7MM MM MM mm
MM MM MM MM MM MM
,pW"Wq. MMpMMMb. `7MM ,pP"Ybd .gP"Ya .gP"Ya mmMMmm MMpMMMb. .gP"Ya MM `7MMpMMMb.pMMMb. MM ,pP"Ybd mmMMmm ,pW"Wq.`7MMpdMAo. ,pP"Ybd
6W' `Wb MM MM MM 8I `" ,M' Yb ,M' Yb MM MM MM ,M' Yb MM MM MM MM MM 8I `" MM 6W' `Wb MM `Wb 8I `"
8M M8 MM MM MM `YMMMa. 8M"""""" 8M"""""" MM MM MM 8M"""""" MM MM MM MM MM `YMMMa. MM 8M M8 MM M8 `YMMMa.
YA. ,A9 MM MM MM L. I8 YM. , YM. , MM MM MM YM. , MM MM MM MM MM L. I8 MM YA. ,A9 MM ,AP L. I8
`Ybmd9'.JMML JMML. .JMML. M9mmmP' `Mbmmd' `Mbmmd' `Mbmo.JMML JMML.`Mbmmd' MM .JMML JMML JMML.MM M9mmmP' `Mbmo`Ybmd9' MMbmmd' M9mmmP'
MM MM MM
MMmmm mmmMM .JMML.
,, ,... ,, ,,
db mm .d' "" `7MM db
MM dM` MM
`7MM mmMMmm mMMmm`7Mb,od8 ,pW"Wq.`7MMpMMMb.pMMMb. ,p6"bo MMpMMMb. ,6"Yb. `7MMpMMMb. .P"Ybmmm `7MM `7MMpMMMb. .P"Ybmmm
MM MM MM MM' "'6W' `Wb MM MM MM 6M' OO MM MM 8) MM MM MM :MI I8 MM MM MM :MI I8
MM MM MM MM 8M M8 MM MM MM 8M MM MM ,pm9MM MM MM WmmmP" MM MM MM WmmmP"
MM MM MM MM YA. ,A9 MM MM MM YM. , MM MM 8M MM MM MM 8M MM MM MM 8M
.JMML. `Mbmo .JMML..JMML. `Ybmd9'.JMML JMML JMML. YMbmd'.JMML JMML.`Moo9^Yo..JMML JMML.YMMMMMb .JMML..JMML JMML.YMMMMMb
6' dP 6' dP
Ybmmmd' Ybmmmd'
,, ,, ,, ,,
`7MM `7MM db `7MM `7MM
MM MM MM MM
,p6"bo ,pW"Wq. MM ,pW"Wq.`7Mb,od8 MM ,MP'`7MM `7MMpMMMb. ,M""bMM ,6"Yb. ,p6"bo ,pW"Wq. ,pW"Wq. MM
6M' OO 6W' `Wb MM 6W' `Wb MM' "' MM ;Y MM MM MM ,AP MM 8) MM 6M' OO 6W' `Wb 6W' `Wb MM
8M 8M M8 MM 8M M8 MM MM;Mm MM MM MM 8MI MM ,pm9MM 8M 8M M8 8M M8 MM
YM. , YA. ,A9 MM YA. ,A9 MM ,, MM `Mb. MM MM MM `Mb MM 8M MM YM. , YA. ,A9 YA. ,A9 MM ,,
YMbmd' `Ybmd9'.JMML.`Ybmd9'.JMML.dg .JMML. YA..JMML..JMML JMML.`Wbmd"MML.`Moo9^Yo. YMbmd' `Ybmd9' `Ybmd9'.JMML.db
,j
,'
Name:
Anonymous2013-02-03 19:15
Don't tell me you just figured that out.
Name:
Anonymous2013-02-03 19:23
8 8
8 8 eeeee eeee eeeee eeeee eeeee e e eeeee eeeee eeeee eeee e e e e eeeee e eeeee
8e 8 8 8 8 8 88 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 "
88 8 8e 8 8eee 8 8 8eee8e 8e 8e 8 8e 8 8eee8 8e 8eee 8e 8eeee8 8e 8e 8e 8eeee
88 8 88 8 88 8 8 88 8 88 88 8 88 8 88 8 88 88 88 88 88 88 88 88
88ee8 88 8 88 8eee8 88 8 88 88ee8 88 8 88 8 88 88ee 88eee 88 88 88 88 88 8ee88
8
8
eeeee eeeee e e eeee 8 eeeee e eeeee eeeee eeeee eeeee e e eeeee eeeee e e e
8 8 8 8 8 8 8e 8 8 8 8 8 8 8 8 88 8 8 8 8 8 8 88 8 8 8
8e 8eee8e 8e 8 8eee 88 8e 8 8e 8e 8 8e 8 8 8 8e 8eee8e 8e 8 8 8 8e 8 8
88 88 8 88 8 88 88 88 8 88 88 8 88 8 8 8 88 88 8 88 8 8 8 88 8 8
88 88 8 88ee8 88ee 88 88 88ee8 88 88ee8 88 8 8eee8 88 88 8 88 8 8eee8 88ee8ee8 88
8
8 eeeee eeeeeee eeeee eeeee e e eeeeeee eeeee eeeee e e e eeeee eeeee e e eeee eeeee eeeee
8e 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 " 8 8 8 8 8 8 8 8 8 8 8 8
88 8eee8 8e 8 8 8eee8 8e 8 8e 8 8e 8 8 8eee8e 8eeee 8eee8 8e 8e 8e 8eeee8 8eee 8eee8 8e
88 88 8 88 8 8 88 8 88 8 88 8 88 8 8 88 8 88 88 8 88 88 88 88 88 88 8 88 "8
88 88 8 88 8 8 88 8 88ee8 88ee8 88 8 8 88eee8 8ee88 88 8 88 88 88 88 88 88 8 88ee8 88
Name:
Anonymous2013-02-03 19:47
Do you come from the imageboards? How can you not know that?
Name:
Anonymous2013-02-03 19:50
>>25
Stop bullying my student, he is a very promising shitposter. Try to be half as creative.
Name:
Anonymous2013-02-03 19:53
>>26
I like him, and I wouldn't call him a shitposter.
But if you really want to go there, get some Hebrew/Cyrillic text art ready.