Questions tagged [number-manipulation]

8 questions
6
votes
4 answers

Return the nth digit of a number

public class Return { public static void main(String[] args) { int answer = digit(9635, 1); print("The answer is " + answer); } static void print(String karen) { System.out.println (karen); } …
Joey
  • 111
  • 3
  • 4
  • 9
2
votes
3 answers

How to break a number into different parts in Java?

I'm looking to do the following : let's say I have a number like 125.625 => I would like to be able to tell my program that is 1 * 100 + 2 * 10 + 5 * 1 + 0.625. How could I do that please ? thanks
BlackLabrador
  • 201
  • 5
  • 13
2
votes
1 answer

Batch: Reordering numbers in a text file

I have a .txt file that contains a list of menu's and commands. What I want to be able to do is incrementally run through each line of this .txt file, check the number, and increment it from the previous value. So, here is an example section of…
Stoating
  • 411
  • 3
  • 6
  • 12
1
vote
4 answers

get the number of the reverse order of a given series

I want to get the number of the reverse order of a given series in javascript. If I have the following series: [1,2,2,2,5,5,7,8,8,10] then if the input is number 8 the output should be 2, since: 1 = 10 2 = 7 2 = 7 2 = 7 5 = 5 5 = 5 7 …
Eng.Fouad
  • 115,165
  • 71
  • 313
  • 417
1
vote
2 answers

Java Bit Operations (In Radix Sort)

The other day I decided to write an implementation of radix sort in Java. Radix sort is supposed to be O(k*N) but mine ended up being O(k^2*N) because of the process of breaking down each digit to one number. I broke down each digit by modding (%)…
Collin Price
  • 5,620
  • 3
  • 33
  • 35
1
vote
6 answers

rounding in base 10

I have a function to round a number given to the function to the nearest whole pence.