Questions tagged [decimal-point]

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.

441 questions
28
votes
2 answers

pandas to_csv arguments float_format and decimal not working for index column

I have the following snippet to export my data as a csv file: rpm = [0.25, 0.3, 0.5, 0.75, 1.0, 1.5, 2.0] df = pd.DataFrame(get_some_data_from_somwhere(), index=rpm) with open('foo.csv', 'w') as f: data.to_csv(f, index=True, header=True,…
albert
  • 8,027
  • 10
  • 48
  • 84
27
votes
3 answers

Int to Decimal Conversion - Insert decimal point at specified location

I have the following int 7122960 I need to convert it to 71229.60 Any ideas on how to convert the int into a decimal and insert the decimal point in the correct location?
Baxter
  • 5,633
  • 24
  • 69
  • 105
25
votes
5 answers

Decimal point or decimal comma in Android

Is there an easy way to read back if the language set uses a decimal comma or a decimal point?
patrick
  • 1,282
  • 4
  • 21
  • 37
25
votes
10 answers

Python, Determine if a string should be converted into Int or Float

I want to convert a string to the tightest possible datatype: int or float. I have two strings: value1="0.80" #this needs to be a float value2="1.00" #this needs to be an integer. How I can determine that value1 should be Float and value2…
ManuParra
  • 1,471
  • 6
  • 18
  • 33
24
votes
2 answers

Change decimal separator in MySQL

Is it possible to change the decimal comma from "." (dot) to other character (comma) in MySQL output? I don't want to use functions like FORMAT, I just want to use all the queries I normaly use without any modification. I'm looking for some setting…
Tomas
  • 57,621
  • 49
  • 238
  • 373
24
votes
3 answers

How to get the numbers after the decimal point? (java)

double d = 4.321562; Is there an easy way to extract the 0.321562 on it's own from d? I tried looking in the math class but no luck. If this can be done without converting to string or casting to anything else, even better.
David
  • 15,652
  • 26
  • 115
  • 156
23
votes
14 answers

Split double into two int, one int before decimal point and one after

I need to split an double value, into two int value, one before the decimal point and one after. The int after the decimal point should have two digits. Example: 10.50 = 10 and 50 10.45 = 10 and 45 10.5 = 10 and 50
Scott Parker
  • 259
  • 1
  • 2
  • 8
16
votes
4 answers

how can i show an irrational number to 100 decimal places in python?

I am trying to find the square root of 2 to 100 decimal places, but it only shows to like 10 by default, how can I change this?
clayton33
  • 4,176
  • 10
  • 45
  • 64
15
votes
5 answers

Javascript restrict input once 2 decimal places have been reached

I currently have a number input script that behaves similar to a calculator with the way numbers are displayed, but I want to stop the adding of additional numbers to the series after two numbers past the decimal point. Here is what I have so far,…
cloudseeker
  • 245
  • 1
  • 2
  • 13
15
votes
3 answers

Converting base of floating point number without losing precision

Terminology In this question I am calling "floating point number" "decimal number" to prevent ambiguation with the float/double Java primitive data types. The term "decimal" has no relationship with "base 10". Background I am expressing a decimal…
SOFe
  • 7,867
  • 4
  • 33
  • 61
15
votes
6 answers

Truncating Double with VBA in excel

I need to truncate the amount of decimal places of my double value for display in a textbox. How would one achieve this with vba?
Ehudz
  • 613
  • 10
  • 22
  • 33
14
votes
3 answers

Python - random float with limited decimal digits

I just found out how to make random numbers in Python, but if I print them out, they all have 15 decimal digits. How do I fix that? Here is my code: import random import os greaterThan = float(input("Your number will be greater than: ")) lessThan =…
SALZKARTOFFEEEL
  • 151
  • 1
  • 1
  • 4
13
votes
6 answers

Format a number containing a decimal point with leading zeroes

I want to format a number with a decimal point in it with leading zeros. This >>> '3.3'.zfill(5) 003.3 considers all the digits and even the decimal point. Is there a function in python that considers only the whole part? I only need to format…
3eee3
  • 155
  • 1
  • 2
  • 7
13
votes
7 answers

Determine the decimal precision of an input number

We have an interesting problem were we need to determine the decimal precision of a users input (textbox). Essentially we need to know the number of decimal places entered and then return a precision number, this is best illustrated with…
Quinten
  • 131
  • 1
  • 1
  • 3
13
votes
4 answers

Sorting 'numbers' with multiple decimal points

I've got a bunch of "numbers" that have multiple decimal points (so they're really strings). However, I want to sort them as if they were numbers. 1.1.1 10.2.3 2.6.7 21.10.4 3.10.12 4.11.5 4.1.16 6.4.23 I want them to sort by the first set of…
thugsb
  • 22,856
  • 6
  • 30
  • 44
1
2
3
29 30