The character or glyph used to separate the integer part from the fraction part in a decimal number. Usually either a dot or a comma.
Questions tagged [decimal-point]
441 questions
                    
                    4063
                    
            votes
                
                91 answers
            
        How to round to at most 2 decimal places, if necessary
I'd like to round at most two decimal places, but only if necessary.
Input:
10
1.7777777
9.1
Output:
10
1.78
9.1
How can I do this in JavaScript?
         
    
    
        stinkycheeseman
        
- 43,437
- 7
- 30
- 49
                    643
                    
            votes
                
                32 answers
            
        Formatting a number with exactly two decimals in JavaScript
I have this line of code which rounds my numbers to two decimal places. But I get numbers like this: 10.8, 2.4, etc. These are not my idea of two decimal places so how I can improve the following?
Math.round(price*Math.pow(10,2))/Math.pow(10,2);
I…
         
    
    
        Abs
        
- 56,052
- 101
- 275
- 409
                    241
                    
            votes
                
                18 answers
            
        How to print a float with 2 decimal places in Java?
Can I do it with System.out.print?
         
    
    
        via_point
        
- 2,563
- 3
- 17
- 9
                    229
                    
            votes
                
                8 answers
            
        How to change the decimal separator of DecimalFormat from comma to dot/point?
I have this little crazy method that converts BigDecimal values into nice and readable Strings.
private String formatBigDecimal(BigDecimal bd){
    DecimalFormat df = new DecimalFormat();
    df.setMinimumFractionDigits(3);
   …
         
    
    
        MiraFayless
        
- 2,353
- 3
- 15
- 8
                    198
                    
            votes
                
                5 answers
            
        Integer.valueOf() vs. Integer.parseInt()
Aside from Integer.parseInt() handling the minus sign (as documented), are there any other differences between Integer.valueOf() and Integer.parseInt()?
And since neither can parse , as a decimal thousands separator (produces NumberFormatException),…
         
    
    
        ateiob
        
- 9,016
- 10
- 44
- 55
                    158
                    
            votes
                
                24 answers
            
        Decimal separator comma (',') with numberDecimal inputType in EditText
The inputType numberDecimal in EditText uses the dot . as decimal separator. In Europe it's common to use  a comma , instead. Even though my locale is set as german the decimal separator is still the .
Is there a way to get the comma as decimal…
         
    
    
        mseo
        
- 3,881
- 3
- 22
- 26
                    136
                    
            votes
                
                11 answers
            
        Javascript: formatting a rounded number to N decimals
in JavaScript, the typical way to round a number to N decimal places is something like:
function roundNumber(num, dec) {
  return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
}
function roundNumber(num, dec) {
  return Math.round(num…
         
    
    
        hoju
        
- 28,392
- 37
- 134
- 178
                    102
                    
            votes
                
                13 answers
            
        Leave only two decimal places after the dot
public void LoadAveragePingTime()
{
    try
    {
        PingReply pingReply = pingClass.Send("logon.chronic-domination.com");
        double AveragePing = (pingReply.RoundtripTime / 1.75);
        label4.Text = (AveragePing.ToString() + "ms");   …
         
    
    
        Sergio Tapia
        
- 40,006
- 76
- 183
- 254
                    88
                    
            votes
                
                3 answers
            
        Simplest way of getting the number of decimals in a number in JavaScript
Is there a better way of figuring out the number of decimals on a number than in my example?
var nbr = 37.435.45;
var decimals = (nbr!=Math.floor(nbr))?(nbr.toString()).split('.')[1].length:0;
By better I mean faster to execute and/or using a…
         
    
    
        PhilTrep
        
- 1,521
- 1
- 10
- 23
                    72
                    
            votes
                
                3 answers
            
        In jQuery, what's the best way of formatting a number to 2 decimal places?
This is what I have right now: 
$("#number").val(parseFloat($("#number").val()).toFixed(2));
It looks messy to me.  I don't think I'm chaining the functions correctly.  Do I have to call it for each textbox, or can I create a separate function?
         
    
    
        Iain Holder
        
- 14,172
- 10
- 66
- 86
                    58
                    
            votes
                
                2 answers
            
        How to control number of decimal digits in write.table() output?
When working with data (e.g., in data.frame) the user can control displaying digits by using
options(digits=3) 
and listing the data.frame like this.
ttf.all
When the user needs to paste the data in Excell like this
write.table(ttf.all,…
         
    
    
        userJT
        
- 11,486
- 20
- 77
- 88
                    51
                    
            votes
                
                3 answers
            
        What is the decimal separator symbol in JavaScript?
A thought struck me as I was writing a piece of JavaScript code that processed some floating point values. What is the decimal point symbol in JavaScript? Is it always .? Or is it culture-specific? And what about .toFixed() and .parseFloat()?  If…
         
    
    
        Vilx-
        
- 104,512
- 87
- 279
- 422
                    46
                    
            votes
                
                7 answers
            
        How to display a number with always 2 decimal points using BigDecimal?
I am using BigDecimal to get some price values. Requirement is something like this, what ever the value we fetch from database, the displayed valued should have 2 decimal points.
Eg:
fetched value is 1 - should be displayed as 1.00
  fetched value…
         
    
    
        user1391730
        
- 461
- 1
- 4
- 3
                    36
                    
            votes
                
                8 answers
            
        Convert decimal mark when reading numbers as input
I have a CSV file with data reading that I want to read into Python. I get lists that contain strings like "2,5". Now doing float("2,5") does not work, because it has the wrong decimal mark. 
How do I read this into Python as 2.5?
         
    
    
        Till B
        
- 1,248
- 2
- 15
- 19
                    32
                    
            votes
                
                17 answers
            
        How can I limit the number of decimal points in a UITextField?
I have a UITextField that when clicked brings up a number pad with a decimal point in the bottom left. I am trying to limit the field so that a user can only place 1 decimal mark  
e.g.
2.5 OK
2..5 NOT OK  
         
    
    
        user1282180
        
- 1,103
- 3
- 11
- 20