Top "Digits" questions

Questions dealing with getting, manipulating, or changing the digits of numbers

How to round a number to n decimal places in Java

What I would like is a method to convert a double to a string which rounds using the half-up method …

java decimal rounding digits
Check if string contains only digits

I want to check if a string contains only digits. I used this: var isANumber = isNaN(theValue) === false; if (isANumber){ .. } …

javascript numbers digits
Efficient way to determine number of digits in an integer

What is a very efficient way of determining how many digits there are in an integer in C++?

c++ integer digits
Controlling number of decimal digits in print output in R

There is an option in R to get control over digit display. For example: options(digits=10) is supposed to give …

r precision digits r-faq output-formatting
Get number of digits with JavaScript

As the title of my post suggests, I would like to know how many digits var number has. For example: …

javascript count digits
Sum the digits of a number

If I want to find the sum of the digits of a number, i.e.: Input: 932 Output: 14, which is (9 + 3 + 2) What …

python sum digits
C++ - how to find the length of an integer

I'm trying to find a way to find the length of an integer (number of digits) and then place it …

c++ count numbers integer digits
How do I separate an integer into separate digits in an array in JavaScript?

This is my code so far: var n = 123456789; var d = n.toString().length; var digits = []; var squaredDigits = []; for (i = d; …

javascript arrays digits
C: how to break apart a multi digit number into separate variables?

Say I have a multi-digit integer in C. I want to break it up into single-digit integers. 123 would turn into 1, 2, …

c math numbers digits digit
Gets last digit of a number

I need to define the last digit of a number assign this to value. After this, return the last digit. …

java return digits