Questions tagged [digits]

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

Use this tag for questions dealing with getting, manipulating, or changing the digits of numbers. More about digits on wikipedia

1098 questions
-3
votes
1 answer

Java : Parse NumberFormat Object and assign it to Number Object

I had setted maximum fraction digits as 4, but why is the output of N.doublevalue() 1234.56789999999 not 1234.5679? try{ NumberFormat NF = NumberFormat.getInstance(); NF.setMaximumFractionDigits(4); NF.setMinimumFractionDigits(3); …
F. Zheng
  • 13
  • 2
-3
votes
5 answers

How do i determine the first digit of a number without knowing the number of digits?c++

For example, 42556. How do I determine first digit if I don't know the number of digits in the number? I could't find an algorithm that suits me anywere! (I mean to determine the 4 in 42556)
-3
votes
2 answers

Find Number of digits including 00000

I have to input a five digit card # I tried this but realized 00000 wouldn't work if(credit_card_number > 99999) { cout << "CREDIT CARD NOT VALID TRY AGAIN TO MANY DIGITS\n"; credit_card_valid = 0; } …
Kyle Walls
  • 13
  • 1
-3
votes
3 answers

Getting the summation of the 1,2 and 3 digits numbers from text file in perl

Suppose a set of numbers is given in a file number_list.txt. Find the sum of the numbers from the file in the following categories: Sum of all 1 digits numbers Sum of all 2 digits numbers Sum of all 3 digits numbers Sum of all numbers starting…
-3
votes
2 answers

Reversing a number's digits using modular division

My homework is to find the "emirp numbers" (pairs of primes like 13 ⇆ 31) up to 10,000. I can reverse the digits using [::-1], but I must do it with % instead. Here's my code. It works, but how can I reverse the digits using % instead of…
-3
votes
2 answers

Find the sum of the digits of the number entered?

I want to find the sum of the digits of the number entered in JAVA. I want to encode this algorithm. Please enter a number= 4562 sum= 4+5+6+2 and I would like to divide the sum of the last number sum=17/2 but I did not get to separate these…
-3
votes
2 answers

How do I return an array containing the digits of the initial number

Given a non-negative integer, I need to return an array containing the digits of the initial number, considering that the initial number shall be less than 100,000. For example: separateDigits(93) → {9, 3} separateDigits(125) → {1, 2,…
user5183901
  • 159
  • 1
  • 1
  • 6
-3
votes
3 answers

How to sum integers digits

here's my task: I want to sum the digits of an int, problem is I don't know how many digits there are (and I can't ask the user). Is there anything like a getchar for int? I've also tried int c = getchar(), but it isn't working. Thanks:) I wanted it…
bananabread76
  • 37
  • 1
  • 1
  • 9
-3
votes
2 answers

How to create a program that be able to get the two numbers with a maximum of 1000 digits from the user and then print the result?

I'm trying to create a program that be able to get the two numbers with a maximum of 1000 digits from the user and then print the result (with C (programming language)) notes to create this program : 1-to get the two numbers, use strings with a…
-4
votes
1 answer

Question is Find the 2nd largest digit ,What is wrong with my code, I am a beginner

Question is Find the 2nd largest digit ,What is wrong with my code, I am a beginner ,Output is still zero a = input("Enter your number") max = 0 maxx = 0 list1 = [] for i in a : list1.append(i) if i > str(max) : max = i …
-4
votes
1 answer

Read an Integer as int and check for repeating digits

I have to enter a number(int) from the console and to check for a repeating digits in this number, but I must not use an array, and here I find it difficult. Can anyone help me with a code?
-4
votes
1 answer

Create a number with several digit in C++

I have 3 digits (1,4,6) and I want to create a number with 2 digits from my digits like 11,14,16,41,44,46,61,64,66. What command should I use in c++ ?
user11536587
-4
votes
1 answer

Finding all solutions to equation using recursion

I've been given a task to write program in C using recursion. The program is given an equation as a string, such as "123+123=246". My task is to determine, whether the equation is right. The catch is, that numbers in the equation are sometimes…
George
  • 3
  • 1
-4
votes
2 answers

Javascript - Cannot check whether a number in array

This is a terrible situation. I want to check whether a number is in given array of numbers. But it returns mysterious result. Here is my captured console image. I also check the type of a number and elements in array. Blue one has number type…
Luis Kang
  • 251
  • 1
  • 4
  • 15
-4
votes
3 answers

Swap every two digits

How can I with PHP swap every two digits in a long number value? You can see an example below: Example: 12345678 Converted to: 21436587
user1273409
  • 39
  • 3
  • 9