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.

Decimal is the base-10 positional numeral system. It is the ordinary numeral system we use; it can be used to represent both integers and (using a decimal point) non-integer values.

Related tags

7532 questions
2
votes
1 answer

Convert float to decimal, why need explicit conversion?

i have known the decimal type is more preciser than float, so i think it should be reasonable that converting float to decimal will like converting float to double. But in realty, it doesn't true. float a = 1.1f; double d = a; decimal c =…
Jerry
  • 23
  • 4
2
votes
0 answers

Use of clamp bit in python decimal

The python doc on decimal about the clamp bit says: A clamp value of 1 allows compatibility with the fixed-width decimal interchange formats specified in IEEE 754. When clamp is 1, the exponent range is more limited. But what is the use case for…
Saleh
  • 1,819
  • 1
  • 17
  • 44
2
votes
1 answer

Decimal out of range C# and SQL Server

I have a C# Entity Framework class like this: public class Card { public decimal CardNumber { get; set; } } In the database, this value is stored something like this: [card_number] [decimal](38, 2) NULL Then when I go to run this code: …
2
votes
1 answer

How to convert big hex strings to decimal strings?

I am working with big numbers in Rust, my inputs come in as hex strings and I am using a hash function which has done all the heavy lifting with large numbers, all I need to do is to provide it with decimal string versions of the numbers (not…
TIZ
  • 131
  • 8
2
votes
4 answers

Why is the data stored in a Float datatype considered to be an approximate value?

I've never understood why a float datatype is considered an approximation while a decimal datatype is considered exact. I'm looking for a good explanation, thanks.
2
votes
0 answers

Trying to round last section to two decimal places in terms of discount

I cannot figure out rounding to two decimals for the cost with a discount and without a discount. print('You are welcome to the AMC Movie Theaters. There are three categories of ticket prices based on age:') print('1. Children (ages 2-12) costs…
2
votes
0 answers

Multiplication long and decimal numbers in python... wrong result?

I am trying to understand this. if I want to multiply a long and decimal number... I get the wrong result. Example: >>>import decimal >>>division = decimal.Decimal(818191513483616911) / decimal.Decimal(2) >>>print(division) 409095756741808455.5 …
CncMess
  • 23
  • 5
2
votes
3 answers

MySQL - storing numbers with decimal point

exist any way to store in database a numbers with or without decimal point? The user can store to database numbers like 10 and 10.1 - for storing numbers in MySQL I use data type column decimal, so for this example, in the database will be stored…
user1946705
  • 2,858
  • 14
  • 41
  • 58
2
votes
4 answers

Regex decimal with a second decimal point at the end

We have a table in Hana with temperature data. Years ago the genius decision was made in our old database to make the temperature field String since temps were added manually and they could use it to add exception codes and text when a temp was bad…
2
votes
1 answer

Trying to find the inverse of the matrix in C, but the program is not calculating correctly

There was a question that I needed to find the inverse of the matrix (actually it's about cryptography, but never mind) and to be honest the code works. Nevertheless, if you insert certain numbers into the matrix, the program just fail in to…
Yuri
  • 33
  • 4
2
votes
2 answers

php preg_match_all results from (numerical) STRING to DECIMAL - type

I have script that identifies with preg_match_all some numbers from a given file and in a given format '#(\d\,\d\d\d\d)#' (decimal, with 4 decimals). With them, later, I need to do some math operations to find out the sum, average etc. With print_r…
user927495
  • 73
  • 1
  • 1
  • 4
2
votes
1 answer

How to capture DivisionUndefined error in decimal

I'm trying to capture the DivisionUndefined error. However I can only capture the parent error InvalidOperation. from decimal import Decimal, DivisionUndefined try: Decimal('0')/Decimal('0') except DivisionUndefined: print('spam') Expected…
aligen
  • 25
  • 4
2
votes
1 answer

Saving rust_decimal to mongodb

I'm trying to save a rust_decimal::Decimal object in MongoDB. My first attempt was generally: // self.db is of type mongodb::sync::Database decimal = Decimal::new(1, 20); let order = doc! {"decimal":…
2
votes
6 answers

Limit Numbers after Decimal on Key Press Event

I am using the following code to take only digits from user and only one decimal point , that is working fine for me on KeyPress Event : if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.') { e.Handled = true; } if…
Shahid Ghafoor
  • 2,991
  • 17
  • 68
  • 123
2
votes
0 answers

IEEE 754-2008 Decimal Floating Point. Why though?

IEEE 754-2008 added storage formats for decimal floating-point numbers, i.e. floating-point numbers with a radix of 10 instead of 2. IEEE 854 already defined operations on these kinds of numbers, but without a storage format, and it never saw…
Feuermurmel
  • 9,490
  • 10
  • 60
  • 90
1 2 3
99
100