Tags
 IOS SQL HTML C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6

# Why does my string not display with the decimal points I want?

By : Ki-young Kim
Date : September 15 2020, 07:00 AM
I hope this helps . I am trying to make a program where if I input the degree, it converts it into radian and then calculate its Sine, Cosine and Tangent using Taylor's Theory. Note that I am not supposed to invoke the math module. , You are missing a .:
code :
``````print("{0}{1:.{2}f}".format("sin= ", sinAns(rad), precision))
# ^
``````

Share :

## Convert string value into decimal with proper decimal points

By : Sam
Date : March 29 2020, 07:55 AM
this one helps. i have value stored in string format & i want to convert into decimal. , As already commented 11.1 is the same value as 11.10
code :
``````decimal one=11.1;
decimal two=11.10;
Console.WriteLine(one == two);
``````
``````decinum.ToString("0.00");
``````
``````string input="11.10";
decimal result;

if (decimal.TryParse(input,out result)) {
Console.WriteLine(result == 11.10);
} else {
// The string wasn't a decimal so do something like throw an error.
}
``````

## Java String.format two decimal places with points as thousand seperators and a comma as the decimal seperator

By : tborgia10
Date : March 29 2020, 07:55 AM
may help you . You can try using DecimalFormat class to format your numbers as you wish :
code :
``````float number = 12344.12f;

DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setGroupingSeparator('.');
symbols.setDecimalSeparator(','); // to be sure it is ','

DecimalFormat decimalFormat = new DecimalFormat();
decimalFormat.setDecimalFormatSymbols(symbols);
decimalFormat.setMaximumFractionDigits(2);

String format = decimalFormat.format(number);

System.out.println(format);
``````
``````12.344,12
``````
``````DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setGroupingSeparator('.');
symbols.setDecimalSeparator(','); // to be sure it is ','

DecimalFormat decimalFormat = new DecimalFormat("#.###.00");
decimalFormat.setDecimalFormatSymbols(symbols);

String format = decimalFormat.format(number);
``````

## How to display decimal points?

By : anil
Date : March 29 2020, 07:55 AM
This might help you 1, 5, 25, 10 are integers, so calculating with them will produce integer results. Try double x = 1.0/5.0 and double y = 25.0/10.0.

## How to only display decimal points to 2 decimal places only when there aren't trailing zeroes

By : Rohit
Date : March 29 2020, 07:55 AM
it should still fix some issue I've been trying to to display decimal points to 2 decimal places for a multiplication operation: , Use printf with precision specifier:

## How to display maximum 2 decimal points if we have less than 2 decimal point it should display real value in SQL Server

By : Venkatesan B
Date : March 29 2020, 07:55 AM
I wish did fix the issue. Clearly this belongs in the Presentation Layer, but if you must...
Example
code :
``````Declare @YourTable table (Value decimal(16,6))
Insert Into @YourTable values
(10.00)
,(10.3)
,(10.53)
,(10.246)

Select *
,NewString = format(round(Value,2,1),'0.##')
From @YourTable
``````
``````Value       NewString
10.000000   10
10.300000   10.3
10.530000   10.53
10.246000   10.24   -- Note not rounded to 10.25
``````