Questions tagged [decimal]
Decimal is the name for our common base-ten numeral system. It may also refer to non-integer values expressed with a decimal point.
7,198
questions
-1
votes
1
answer
14
views
Why need to keep three decimal places ? two decimal places rounding problem
I am facing a problem rounding amounts into two decimal places. The total amount is not matching with breakdown amount
<ORDER_TOTAL_TAX>75.83</ORDER_TOTAL_TAX>
I know the total tax is 75....
1
vote
1
answer
19
views
How to change text to decimal in MySQL?
I have plenty of values(previously percentages) of data type text in my MySQL dataset.
They all look like 24.05, 0.25, 46.3, 5.2, etc.
I want to convert these to a data type that will allow me to ...
0
votes
3
answers
71
views
Swift get decimal value for String characters
Is it possible to get the decimal value for String characters in Swift?
something like:
let words:String = "1 ring to rule them all"
var value:Int = 0
for i in 0..<words.count {
let ...
0
votes
2
answers
29
views
Confused on float and integers, how to make the output exactly as it is, not round up or unnecessary ".0"
I'm trying to make a code to find the gradient of a straight line for my assignment.
It went well but unfortunately it didn't pass 3 test case because the output has decimals so it rounds up the ...
0
votes
0
answers
18
views
Reading a decimal value from a text value into 2 variables
Been trying to read from 2 seperate text files, 2 seperate decimal values. Unfortunately batch doesn't seem to be able to do this so, as I am just going to paste the values into another text document, ...
0
votes
0
answers
31
views
Remove Currency Character from Currency String in C# [duplicate]
How can I remove the currency character from a currency string e.g. 20,000.00 €?. I need only the numeric figure for further processing the data. I have tried with decimal.TryParse(temp, NumberStyles....
-2
votes
0
answers
18
views
How to format number in javascript as you type? [duplicate]
I want to format number as the user type.
I tried the following code found in this forum but it doesn't allow decimal.
$(".test").on('keyup', function(){
var n = parseInt($(this)....
-1
votes
1
answer
26
views
How to join two tables based on a decimal column?
I found other posts where people asked about joining sql tables using decimal columns and the general answer is "try to avoid it". But here is a case that I just have to use some kind of a ...
-3
votes
0
answers
35
views
how to reduce decimals in file json python
I am consuming a rest api json web service, how can I control or reduce the decimals, of the "importe" data?
import urllib.request
import re
import json
texto='+51 998 ... ...'
patron = '[\...
-1
votes
0
answers
13
views
Adding period in a string in sql
Data
I have this data where I need to update the Line text in the following way
Line 3 till line 10 :
Requirement : Length of this line is 51 and it needs to remain 51 even after the update (in other ...
-2
votes
1
answer
60
views
Deleting columns with less than 6 decimals in pandas [closed]
I have a dataframe where some of the columns contain floating point numbers with 6 decimals but some columns only have 1 or 2 decimals. I want to delete all columns with less than 6 decimals. I tried ...
-1
votes
1
answer
28
views
Deleting all columns with less than 6 decimals in a dataframe
I want to delete all columns with less than 6 decimals in a pandas dataframe. I've tried filling columns with less than 6 decimals with 0's by pd.options.display.float_format = '{:,.6f}'.format but ...
2
votes
1
answer
34
views
Typo in decimal place + postgresql
I have a data set of students that calculates average scores (to the nearest decimal) as of a certain date.The data set is riddled with typos.
A sample data is:
student_id date avg_test_score
ab_1 ...
-1
votes
1
answer
36
views
SQL Server : unable to save decimal digits
I am facing a peculiar problem. I have a few tables in SQL Server where I have properly declared a few columns as decimal(18, 2).
Unfortunately, whenever, I save any value in these columns, either the ...
0
votes
0
answers
16
views
Displaying decimal numbers on 2D array grid view
I am trying to create a 2D grid with the following features:
It will have more than 100 X and Y cells, so I cannot show them all on the screen. Therefore, I want the user to be able to slide it to ...
0
votes
1
answer
50
views
Rounding columns in a dataframe with file.dtypes.iteritems()
I'm making a function on rounding decimals, I wrote the following already:
for colname, coltype in file.dtypes.iteritems():
if coltype in lst:
file[colname] = file[colname].round(...
0
votes
1
answer
56
views
How to prevent automatically rounding the decimal part of the number in .NET 6
After I converted the version from .NET Core 3.1 to 6.0, I figured out that all decimal(10, 5) type columns were automatically rounding the decimal part of the number and saved it in the database with ...
0
votes
0
answers
32
views
PowerShell - Import-CSV - How can I keep leading zeros on all decimal numbers being imported
I am trying to perform changes to a existing CSV, such as keeping specific columns (and removing the rest). However when I use Import-CSV, the leading zeros on certain data is being converted from 0....
0
votes
0
answers
36
views
Minimal decimal number in pandas dataframe
I'm trying to make a dataframe in pandas where all columns have at least 6 decimals. I've tried splitting the decimal numbers on their . and look at the decimal length accordingly. There must be an ...
-1
votes
0
answers
14
views
Ho to convert base 10 floating point input to base 2 in MIPS?
I have been tasked with writing a program in MIPS that converts a user-inputted base 10 floating point number to base 2. I am a relatively inexperienced programmer and have almost no prior experience ...
-2
votes
0
answers
36
views
is there a way to store very long (>100) decimal places in C#? [duplicate]
I would like to approximate euler's number e for a school project. However, in most languages, you can only store around 30 decimal places. I would like to calculate around a hundred or more. is there ...
0
votes
1
answer
26
views
Round decimals in Java
Im trying to round some double decimals, because I am getting only 0.0 as result of division.
I tried using the BigDecimal way and the String.format(), however I still get O.00 at:
Relation Aromatics/...
0
votes
1
answer
27
views
convert a filename eg file01010101 from decimal to binary using two's complement, without using built in binary function in bash
This is the binary evaluation and conversion part of the shell script.
elif [[ $file == file[0-1][0-1][0-1][0-1][0-1][0-1][0-1][0-1] ]]
then
first=`echo $file | cut -c 5`
second=`echo $file | ...
0
votes
1
answer
42
views
Printing decimal precision upto desiired number in cpp
I have an application I want to print the precision of the calculated prime number up to the desired number. But the number is omitted on the terminal as shown below.
The code I used for this is as
...
1
vote
2
answers
47
views
Evaluating strings without eval()
In Python, can I evaluate a string (eg. “math.sin(3)+max(5,3)”) without using the dreaded eval(), and preferably with Decimal precision? Note: it is not a simple mathematical expression such as "...
0
votes
2
answers
35
views
Round to 2 Decimal Places Even with Zeros
I am currently using the following logic to round to round to 2 decimal places:
billables_all["Parts Charged"] = billables_all["Parts Charged"].fillna(0).round(2)
billables_all[&...
0
votes
0
answers
53
views
Angular input field type number should allow only numbers from 0-9
Having an input field where the user will enter the amount in it. i do want to restrict the users from entering decimal points.
Eg : if user tries to enter 121.2 , i should not allow him to place '.'(...
0
votes
1
answer
27
views
Using format() in R to convert numeric value to scientific notation after rounding
A small snippet of my overall code is to round a given vector to a specified number of decimal places. The rounded value is then converted to standard notation, e.g. "1.2e-01".
The following ...
-2
votes
1
answer
27
views
Why does subtracting decimals not work in javascript [duplicate]
If I do the code below and enter a decimal for one or both of the numbers, lets says I use 0.5 and 0.3, I should get 0.2 but I get 0 only. This makes no sense at all to me, it is probably a problem ...
0
votes
0
answers
16
views
XmlSerializer does not serialize a property named Quantity (decimal)
I having a problem with a serialization of a property in my class.
In detail: I generated a service client (C#) from a wsdl(made by a java service) gave me from another company, once I fill the ...
0
votes
1
answer
27
views
None of the decimal rounding methods I know worked for my current need (converting string from a fractional odds to decimal odds)
The values in the a list are the math division values that come from the API.
To convert a string into a calculation, I use eval().
The values in correct_list are the final results of this division ...
0
votes
1
answer
52
views
Multiline Hex to Decimal converter
I'm trying to make a hex to decimal converter for large amounts of hex numbers.
{
textBox1.Text = textBox1.Text.Replace("-", "");
textBox1.Text = textBox1.Text....
-2
votes
1
answer
83
views
What does this error mean, and how do I rectify it?
system.overflow exception: value too small or too large
I'm busy with a loan calculator app. In the code below, I'm trying to calculate the loan payment (paymentD; payment) to push into a loan object. ...
1
vote
2
answers
34
views
Kotlin - How to eliminate decimals except the first two
What I want to achieve is to keep 2 decimals and eliminate any extra decimals without any rounding for example
3.556664 to 3.55 (NOT ROUNDING)
I Tried the following
"%.2f".format(3.556)....
0
votes
0
answers
15
views
BCP QUERYOUT how to change length to all decimal fields
I export SQL tables to txt files (by the code below in ssms)
all the columns are exported well except decimal columns,
which export 41 chars (I want 19 chars),
even the size column is 14(4)
how can I ...
2
votes
1
answer
40
views
how to control the decimal points in r, during the whole process
how can I control the decimal point in r?
Not only for printing but all the process.
options(digits=3) do not seems to work, because
some of my statistics are 1000.9844 like this and
some of my ...
0
votes
1
answer
22
views
Best way to return price with decimals from Model
In my model I have total price calculation based on hasMany relationship. It looks like this:
public function totalPrice(): string
{
return num_format($this->hasMany(Direction::class)->sum('...
0
votes
0
answers
15
views
Set output size in bc library
I'm using the bash bc library to perform inter-base conversions. Does anyone know if it is possible to set the output size (number of bits/bytes)? I need his output size defined so I can confirm ...
1
vote
1
answer
41
views
SQL Server - Decimal values not precisely calculated
For the below calculation, the expected result is -0.0000671. But the result of the code is -0.00006800000.
declare
@V_A decimal (38,11) = 99.99329,
@V_B decimal (38,11) = 100,
...
0
votes
0
answers
37
views
How does this code convert the decimal to binary? [duplicate]
Having difficulty to understand this code. Can somebody explain to me in a simple way.
# decimal to binary
def convert(num):
if num == 0:
return 0
else:
#explain this part
...
0
votes
0
answers
15
views
Handling Commas and Decimals in HTML JS equations? [duplicate]
I'm used to using Visual Studio and when programming mathematical equations it's possible to build a program that allows for both commas and decimals to be used (obviously handy, pending on the region ...
0
votes
0
answers
21
views
Why are base-32 numbers usually not used in programming?
Usually, programming languages support binary, octal, decimal, and hexadecimal numbers. But, base-32 numbers are usually not used in programming. I never seen a code that uses base-32 numbers. Base-32 ...
1
vote
1
answer
17
views
How to change the value format for a specific column - R
Suppose that I have a dataset traffic with a column Traffic_count that displays the traffic count for each traffic counting station:
Traffic_counting_station_ID
Traffic_count
1
24.592
2
65.500
3
4....
0
votes
0
answers
18
views
How to format currency inside a xs:decimal format in xsd
Taking an XML class and I'm struggling to format the currency code and the phone numbers in the way the book wants. When I try to validate to make sure it works, it either comes up as invalid or doesn'...
0
votes
1
answer
26
views
append decimal point in the middle of integer in postgres
I'm doing a report from our database regarding some amount
It shows like this in the report from the front end
however in the backend it's like this
It seems that the system adds a decimal point ...
0
votes
0
answers
19
views
asp:SQLDataSource-Conversion from string to double is not valid
I am trying to change oracle client in my vb.net application from System.Data.OracleClient to System.Data.Oledb & getting Invalid Cast Exception (Conversion from string to type Double is not valid)...
-1
votes
2
answers
52
views
calculating more the 19 digits of division
I want to make a python program that divides '1/7' in python however all I get is : 0.14285714285714285. How can I compute more digits after the decimal?
0
votes
1
answer
30
views
github.com/shopspring/decimal: different values produced by FromString and FromFloat
I'm trying to use gomock to mock an interface that takes a decimal. The usecase:
v, err := decimal.NewFromString(order.Value)
if err != nil {
return err
}
if err := p.CDI.CreateBuyEvent(ctx, v); ...
0
votes
0
answers
27
views
What is the simplest way to output financial decimal answers for beginners using JavaScript? [duplicate]
Example: convert calculated integer answer 24.025724 into 24.03
For the time being, I convert all decimal numbers into whole numbers to do the calculations by multiplying them by 100, then divide the ...
0
votes
1
answer
44
views
Checking if the number is a decimal.Decimal type in python
Variable 'a' could be of type - int/float/decimal.Decimal (but not a string)
I want to check if its a decimal.Decimal type.
Following works:
import decimal
a = decimal.Decimal(4)
if type(a) is ...