function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sushant sussushant sus 

Getting wrong result in adding two double datatype no

Please help .............

 

my line of debug

 

 system.debug('11111111133311'+sumcheck);    
                                system.debug('1111111111767771'+sumchek2);  
                                system.debug('00000000000000'+sumchekaborted);  
                                
                                system.debug('11111111199999911'+parentmap.get(c2.parentid).BudgetedCost);
                                sumchek3 = (sumcheck + sumchek2);
                                system.debug('1111115555555555'+sumchek3); 

 

sumcheck3 should show 50,000 but is showing 85000 as sumchek2 is 0.0 and sumcheck is 50,000

 

 

now debug log

 

17:17:18.077 (77731000)|USER_DEBUG|[319]|DEBUG|1111111113331150000.0
17:17:18.077 (77736000)|SYSTEM_METHOD_EXIT|[319]|System.debug(ANY)
17:17:18.077 (77746000)|SYSTEM_METHOD_ENTRY|[320]|String.valueOf(Object)
17:17:18.077 (77759000)|SYSTEM_METHOD_EXIT|[320]|String.valueOf(Object)
17:17:18.077 (77768000)|SYSTEM_METHOD_ENTRY|[320]|System.debug(ANY)
17:17:18.077 (77773000)|USER_DEBUG|[320]|DEBUG|11111111117677710.0
17:17:18.077 (77778000)|SYSTEM_METHOD_EXIT|[320]|System.debug(ANY)
17:17:18.077 (77786000)|SYSTEM_METHOD_ENTRY|[321]|String.valueOf(Object)
17:17:18.077 (77800000)|SYSTEM_METHOD_EXIT|[321]|String.valueOf(Object)
17:17:18.077 (77809000)|SYSTEM_METHOD_ENTRY|[321]|System.debug(ANY)
17:17:18.077 (77814000)|USER_DEBUG|[321]|DEBUG|0000000000000035000.0
17:17:18.077 (77819000)|SYSTEM_METHOD_EXIT|[321]|System.debug(ANY)
17:17:18.077 (77841000)|SYSTEM_METHOD_ENTRY|[323]|MAP<Id,Campaign>.get(Object)
17:17:18.077 (77862000)|SYSTEM_METHOD_EXIT|[323]|MAP<Id,Campaign>.get(Object)
17:17:18.077 (77916000)|SYSTEM_METHOD_ENTRY|[323]|String.valueOf(Object)
17:17:18.077 (77928000)|SYSTEM_METHOD_EXIT|[323]|String.valueOf(Object)
17:17:18.077 (77937000)|SYSTEM_METHOD_ENTRY|[323]|System.debug(ANY)
17:17:18.077 (77943000)|USER_DEBUG|[323]|DEBUG|11111111199999911100000
17:17:18.077 (77948000)|SYSTEM_METHOD_EXIT|[323]|System.debug(ANY)
17:17:18.077 (77971000)|SYSTEM_METHOD_ENTRY|[325]|String.valueOf(Object)
17:17:18.077 (77989000)|SYSTEM_METHOD_EXIT|[325]|String.valueOf(Object)
17:17:18.077 (77998000)|SYSTEM_METHOD_ENTRY|[325]|System.debug(ANY)
17:17:18.078 (78003000)|USER_DEBUG|[325]|DEBUG|111111555555555585000.0
Avidev9Avidev9

Interesting way of doing debug with DOUBLE values......
Dont you think the number mixes with the actual values ?

 

I guess you need to do something about these debug statement may be something like

 system.debug('=======sumcheck============'+sumcheck);  

 

Well this is not an answer, I just felt you should come up with cleaner approach so that people from the community can help you!

 

Neha LundNeha Lund

sumcheck=50,000

and sumcheck2=0

 

Result is proper

souvik9086souvik9086

If you simply do this
sumchek3 = (sumcheck + sumchek2);

then you must get 50,000.

 

But "sumchekaborted" variable is printing 35000 in the debug log.

Is there any operation based on that?

 

Because 50000 + 35000 = 85000 which is coming as your sum. Just check that.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks