Hi, I am calculating arithmetic mean of some $ values, so my numbers should have dollar part and cent part ( two decimal points )
double x = 3.46;
double y = 12. 13;
double arithmeticMean = ( x + y ) / 2; //7.795...should be 7.80
I don't care for stream output, I need to have correct values in memory ( in variable arithmeticMean ).
7.80....arithmeticMean / 2 = 3.9
7.795...arithmeticMean / 2 = 3.8975 //wrong
suljo2 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
ddanbe 2,724 Professional Procrastinator Featured Poster
ArkM 1,090 Postaholic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.