Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem with decimal

Hi experts,

i designed a simple UDF that sums all the value of a segment.

The problem is that in my output I tend to get like 10 decimals!!

Is that normal ? How can I manage to get the value I want??

For example, in my segments I have the following values:

21.00, 15.00, 16.90

as result I get 52.9 which is OK

but when I have 21.00, 15.00, 16.90

the result I get is

52.989999999999995 !!??

How come?my code is the following:

public static void add_all_zvalnet(String[] ZVALNET,ResultList result,Container container){
		double sum = 0;
		for (int i = 0; i < ZVALNET.length; i++){
			sum = sum + Double.parseDouble(ZVALNET<i>);

thx for your help

kind regards,


Former Member
Former Member replied


you shouldn't use double.

Better use BigDecimal.

New Arithmetic and Statistical Functions in Message Mappings in SP18

BTW where is difference in you two input values?



0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question