Questions tagged [decimal-precision]
19 questions
0
votes
4 answers
How to express large numbers to two decimal places in C++ Calculator
I am trying to write a calculator in C++ that does the basic functions of /, *, -, or + and shows the answer to two decimal places (with 0.01 precision).
For example 100.1 * 100.1 should print the result as 10020.01 but instead I get -4e-171. From…

theresthatguy
- 11
- 4
-1
votes
0 answers
Decimal Precision Issue in C# and SQL Server
I am encountering a problem with preserving decimal precision while storing data in SQL Server from a C# application. Here's the scenario:
I have a C# application that retrieves exchange rate data from an API and then stores it in a SQL Server…

Alper Eratilla
- 1
- 1
-1
votes
2 answers
Formatting 0 to include decimal places using DecimalFormat
import java.math.BigDecimal;
import java.text.DecimalFormat;
public class HelloWorld{
public static void main(String []args){
DecimalFormat df = new DecimalFormat("#.##");
System.out.println("two decimals: " + new…

Sara
- 603
- 8
- 19
-2
votes
3 answers
How can I get no more and no less than two decimal places in a decimal value?
With this code:
totalPriceCell.Value2 = TotalPrice;
...I was getting values such as "3.14963245" which I want to be "3.15" instead.
So I used this code:
totalPriceCell.Value2 = TotalPrice.ToString("#.##");
...and that did solve that problem, but I…

B. Clay Shannon-B. Crow Raven
- 8,547
- 144
- 472
- 862