Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 622169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:57:19+00:00 2026-05-13T18:57:19+00:00

I have a csv file where amount and quantity fields are present in each

  • 0

I have a csv file where amount and quantity fields are present in each detail record except header and trailer record. Trailer record has a total charge values which is the total sum of quantity multiplied by amount field in detail records . I need to check whether the trailer total charge value is equal to my calculated value of amount and quantity fields. I am using the double data type for all these calculations. When i browsed i am able to understand from the below web link that it might create an issue using double datatype while comparison with decimal points. It’s suggesting to using BigDecimal

http://epramono.blogspot.com/2005/01/double-vs-bigdecimal.html

Will i get issues if i use double data type. How can i do the calculations using BigDecimal. Also i am not sure how many digits i will get after decimal points in csv file. Also amount can have a positive or negative value.

In csv file

H,ABC…..
“D”,….,”1″,”12.23″
“D”,…..,”3″,”-13.334″
“D”,……,”2″,”12″
T,csd,123,12.345

—————————— While Validation i am having the below code ——————–

                  double detChargeCount =0;

                  //From csv file i am reading trailer records charge value
                  String totChargeValue = items[3].replaceAll("\"","").trim();

                  if (null != totChargeValue && !totChargeValue.equals("")) {
                      detChargeCount = new Double(totChargeValue).doubleValue();

                  if(detChargeCount==calChargeCount)
                      validflag=true;

———————–While reading CSV File i am having the below code

                   if (null != chargeQuan && !chargeQuan.equals("")) {
                          tmpChargeQuan=Long(chargeQuan).longValue();
                         }

                    if (null != chargeAmount && !chargeAmount.equals("")) {
                          tmpChargeAmt=new Double(chargeAmount).doubleValue();
                              calChargeCount=calChargeCount+(tmpChargeQuan*tmpChargeAmt);
                              }

   I had declared the variables  tmpChargeQuan, tmpChargeAmt,   calChargeCount  as double
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:57:20+00:00Added an answer on May 13, 2026 at 6:57 pm

    Especially for anything with financial data, but in general for everything dealing with human readable numbers, BigDecimal is what you want to use instead of double, just as that source says.

    The documentation on BigDecimal is pretty straight-forward, and should provide everything you need.

    It has a int, double, and string constructors, so you can simply have:

    BigDecimal detChargeCount = new BigDecimal(0);
    ...
    detChargeCount = new BigDecimal(totChargeValue);
    

    The operators are implemented as functions, so you’d have to do things like

    tmpChargeQuan.multiply(tmpChargeAmt)

    instead of simply tmpChargeQun * tmpChargeAmt, but that shouldn’t be a big deal.

    but they’re all defined with all the overloads you could need as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a csv file where amount and quantity fields are present in each
Little Background: I have csv file which has lots of rows and each row
I have a CSV file supplied from a client which has to be parsed
I have a csv file, and I want to extract the each column a
Ok so basically I have a csv file with different values. I want each
I have a csv file where each row defines a room in a given
I have CSV file which has timestamp in the first column as shown below
I have a csv file with unknown amount of columns and row. The only
I have a csv file that has column values enclosed within double quotes. I
I have CSV file and Macro in VBA. I want to open CSV file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.