Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To Remove Decimal in Amount field

Status
Not open for further replies.

srvu

Programmer
Apr 29, 2008
49
US
I have Amount field which have value as below say
148.90,148.99
Requirement is to remove the decimal and left pad with zero's.Precision is 9

Value 148.99 is converted correctly as 000014899 but coming to 148.90 its displaying as 000001489, but testers claims it to be
000014890

When we convert a number removing decimal there is no value for 0 i.e. it takes value 148.90 as 148.9 so while removing and left padding its displaying as 000001489.

Kindly help me with the situation
 
How about:

1. Multiply by 100
2. Cast to integer
3. Cast to string
4. Add leading zero's by padding

?

Ties Blom

 
Input precision is 19 and scale is 4.
i am taking it i am taking it as precision 9 and scale 2
Then o/p is coming as say 1239.9000 or 13456.000 so if it is the case i should get number as 000123990 and 001345600
Including digit it is taking number upto 9 length.
In this case how can we multiply with 100

Kindly suggest
 
How are you doing this conversion?
How is your input represented? Is it decimal, float, implied decimal, string, etc?
and your output is implied decimal point of 2 in a string format?

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
My input is to add two amounts and datatype is decimal with precision 19 and scale 4 for both amounts.

Output should be length 9 with padded to zeroes.

Example:

benededuct (benededuct:Double:): "1500.000000000000"
maxoutaccrual (maxoutaccrual:Double:): "3600.000000000000"
lifetimeaccrual (lifetimeaccrual:Double:): "8400.000000000000"
accumvalue1_v (accumvalue1_v:Double:): "101.5000000000000"
accumvalue2_v (accumvalue2_v:Double:): "752.0000000000000"
accumvalue3_v (accumvalue3_v:Double:): "1000.500000000000"
DeductibleAmt_V0 (DeductibleAmt_V0:Double:): "1601.500000000000"
CopayMOPSAmt_v0 (CopayMOPSAmt_v0:Double:): "4352.000000000000"
LifetimeMaxAmt_v0


I should add benededuct+accumvalue1
Maxoutaccrual+accumvalue2
Lifetimeaccrual+accumvalue3


 
IIF(instr(TO_CHAR(DeductibleAmt_V0),'.')>0,TO_CHAR(DeductibleAmt_V0*100),TO_CHAR(DeductibleAmt_V0))

I have used the above Expression

and amoounts for amounts like 160150 is displaying correctly but value 4352 is supposed to be 435200
but it is displaying as 4352 only
 
So what's your conversion logic?

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
According to above logic, it should work for amount like 4352.000000 also but it is displaying 4352
 
Your expression is saying if there is a decimal point, then append two zeroes, otherwise just display the same number (without zero pad).

If you do what Ties suggested, you would always multiply by 100, which gives you the trailing zeroes. Once it's converted to integer, you will drop any extra digits past the decimal. Then convert to string and left pad. No need to check for a decimal point.


"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top