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
11
votes
2 answers

Stopping a large number of zeros being printed (not scientific notation)

What I'm trying to achieve is to have all printed numbers display at maximum 7 digits. Here are examples of what I want printed: 0.000000 (versus the actual number which is 0.000000000029481.....) 0.299180 (versus the actual number which is…
Jase
  • 1,025
  • 1
  • 9
  • 34
10
votes
2 answers

kable displays different number of digits in each column

I am using kable with the knit to Word functionality at work. I find that I often have simple tables with counts as the first column and then a few columns with proportions. I'd like the count column to be rounded to the nearest digit and the…
user3866200
  • 113
  • 1
  • 1
  • 5
9
votes
5 answers

Why float variable saves value by cutting digits after point in a weird way?

I have this simple code line: float val = 123456.123456; when i print this val or look in scope, it stores value 123456.13 Ok, it's fine, it can't store all those digits after point just in 4 bytes, but why does it make 13 after the point?…
Kosmo零
  • 4,001
  • 9
  • 45
  • 88
9
votes
4 answers

What does s[i] - '0' mean?

The following code is from K&R textbook, page number 71: val =10.0*val+s[i] -'0' What does s[i] -'0' mean here?
user5129528
8
votes
1 answer

How to format the number of digits for categorical variables in 'gtsummary::tbl_summary'?

I am unable to figure out how to tell the tbl_summary function to display decimal places when summarizing categorical variables. It works quite well with continuous variables like 'mpg', but not for 'cyl'. library(tidyverse) library(gtsummary) #…
RockinRichi
  • 83
  • 1
  • 3
8
votes
5 answers

How to extract a number into digits using R?

Suppose I have a number: 4321 and I want to extract it into digits: 4, 3, 2, 1 How do I do this?
user2717901
  • 81
  • 1
  • 1
  • 2
8
votes
3 answers

Oracle SQL : search column that starts with digits

I'd like to find all the rows which column value begins with a digit. Its works well with this request : WHERE trim(u_ods_val3.ods_itn_PHRSBMO.NO_ART_TECH_OI) IS NOT NULL AND (SUBSTR(u_ods_val3.ODS_ITN_PHRSBMO.NO_ART_TECH_OI,0,1)='0' OR…
twopheek
  • 1,035
  • 2
  • 8
  • 10
8
votes
4 answers

Weird error in R when importing (64-bit) integer with many digits

I am importing a csv that has a single column which contains very long integers (for example: 2121020101132507598) a<-read.csv('temp.csv',as.is=T) When I import these integers as strings they come through correctly, but when imported as integers…
Zubin
  • 167
  • 2
  • 7
7
votes
7 answers

Counting digits using while loop

I was recently making a program which needed to check the number of digits in a number inputted by the user. As a result I made the following code: int x; cout << "Enter a number: "; cin >> x; x /= 10; while(x > 0) { count++; x =…
E.O.
  • 794
  • 6
  • 16
  • 24
7
votes
8 answers

Only accept digits for textbox

I found this code for making my textbox only accept numbers. Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Dim allowedChars As String = "0123456789" …
Saturn
  • 17,888
  • 49
  • 145
  • 271
7
votes
5 answers

Regular expression for 1-50 without decimal point

I am looking for a regular expression that will match any number from 1 to 50 inclusive. So far, I have found examples but they all allow the string to contain a decimal point, which I do not want to include. So 1,13,24,50 are OK but 1. ,etc are…
Tim
  • 71
  • 1
  • 1
  • 3
7
votes
7 answers

Sort N numbers in digit order

Given a N number range E.g. [1 to 100], sort the numbers in digit order (i.e) For the numbers 1 to 100, the sorted output wound be 1 10 100 11 12 13 . . . 19 2 20 21..... 99 This is just like Radix Sort but just that the digits are sorted in…
Mor Eru
  • 1,129
  • 3
  • 18
  • 35
7
votes
4 answers

How to put digits of an integer in a vector in C++

If a user enters an integer like 4210 for example, how can I put each digit of that integer in a vector in C++?
Mohamed Ahmed
  • 457
  • 1
  • 7
  • 25
7
votes
5 answers

Is using `str` the correct idiom for working with digits in Python

I understand that one way to work with the digits of a number in Python is to convert the number to a string, and then use string methods to slice the resulting "number" into groups of "digits". For example, assuming I have a function prime that…
orome
  • 45,163
  • 57
  • 202
  • 418
7
votes
2 answers

Display decimals two digits unless integer

Multiplication of two numbers $(document).ready(function () { $("#input1, #input2").change(function () { var num = parseFloat($("#input1").val()) * parseFloat($("#input2").val()); if (num % 1 != 0) { num =…
june8
  • 609
  • 1
  • 6
  • 12