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

String.Format decimal with sign, fixed number of decimal places, no decimal separator

What is the cleanest, most readable way to String.Format a decimal with the following criteria start with a sign symbol (+ or -) a fixed number of fraction digits no decimal separator right aligned pre-padded with "0"'s For example 123,45 would…
Boris Callens
  • 90,659
  • 85
  • 207
  • 305
3
votes
4 answers

How to write Fraction as decimal with x DPs in Python?

What I'm looking for is a way to write out a python Fraction() type to an arbitrary number of decimal places. I've looked at the python docs for Fraction and Decimal, but I can't see any way to convert or to write out the Fraction. So what I'm…
Jack TC
  • 344
  • 1
  • 5
  • 17
3
votes
2 answers

VHDL Clock Divider With Decimals

I'm trying to slow a 50MHz clock down to 25.175MHz for use in a VGA controller. I have a clock divider already, but am having trouble slowing the clock down whenever the resulting division of the current clock speed and the desired clock speed is…
Eric Townsend
  • 201
  • 2
  • 6
  • 13
3
votes
4 answers

Sin, cos etc for Python 2 Decimal?

In Python 2.6, I found that the Decimal equivalent of sqrt(pi) is Decimal(pi).sqrt() Is there anything like that for sin, cos or other (inverse) trigonometric functions? The docs only mention how to calculate cos and sin computationally.…
Mark
  • 18,730
  • 7
  • 107
  • 130
3
votes
2 answers

How to store average rating in MySQL?

What MySQL data type suits best for storing average rating values, like movie ratings on IMDB? FLOAT, DECIMAL? Or maybe it will work faster if I round actual values to two decimal places in PHP and save it like INT (8.323243 -> 8.32 -> 832)?
Kadilov
  • 145
  • 1
  • 6
3
votes
4 answers

Android - numeric keyboard with decimal separator

I have an edittext which is created programmatically (so not in xml) and I want to launch a numeric keyboard when user presses it. The problem is that I want this keyboard also to contain the decimal separator (.). I tried many things but nothing…
george
  • 1,386
  • 5
  • 22
  • 38
3
votes
7 answers

convert decimal to 32 bit binary?

convert a positive integer number in C++ (0 to 2,147,483,647) to a 32 bit binary and display. I want do it in traditional "mathematical" way (rather than use bitset or use vector *.pushback* or recursive function or some thing special in C++...),…
Ronaldinho Learn Coding
  • 13,254
  • 24
  • 83
  • 110
3
votes
1 answer

Using decimal data type to work with monetary values with db2 and delphi 2010

I'm using delphi 2010 with db2 9.7 Express-C and I have a database that has several fields of decimal type to work with monetary values. Now I see that there are some problems using it, like the 9.20 value displays the value 9.19999980926514 in my…
Sammy Davis
  • 117
  • 4
  • 13
3
votes
2 answers

Can I use the $string number_format line to superscript my decimals?

I would like to make the decimals in the following string display as superscript: $string .= number_format(round($value, (int)$decimal_place), (int)$decimal_place, $decimal_point, $thousand_point); I'm not very smart but I have been trying since…
Stefan
  • 95
  • 2
  • 13
3
votes
2 answers

Convert decimal number to minutes and seconds using VBA

I have time represented by a decimal number that I need to convert to minutes and seconds in Excel using VBA. Example: The number before the decimal point gives the minutes as 0.197683577 (0 minutes) and the number multiplied by 60 gives the…
user1371038
  • 131
  • 1
  • 2
  • 5
3
votes
4 answers

javascript, issue with number rounding

I knew javascript could have rounding issue with divisions, but not with multiplication. How do you solve those? var p = $('input[name="productsUS"]').val().replace(",", "."); var t = $('input[name="productsWorld"]').val().replace(",", "."); if (p…
Kraz
  • 6,910
  • 6
  • 42
  • 70
3
votes
3 answers

Can I move a decimal in javascript without math?

I would love to be able to move a decimal point 2 places across an unknown amount of numbers without using math. I know that seems weird, but finite precision causes some shifts. My javascript is not strong, but I'd really like to learn how to chop…
Dan Denney
  • 290
  • 2
  • 14
3
votes
4 answers

converting string to decimal in c#

I am having some problems converting string to decimal values with decimal.parse. This is the line of code I have: fixPrice = decimal.Parse(mItemParts.Groups["price"].Value.Replace("$", "").Replace(" ", "").Replace("usd", "")); The value from…
Laziale
  • 7,965
  • 46
  • 146
  • 262
3
votes
2 answers

TSQL: Which real number type results in faster comparisons

Among TSQL types (MSSQL): real, float and decimal; which type would result in faster comparisons? Would decimal use hardaware FPU computation or is it purely in software?
loopedcode
  • 4,863
  • 1
  • 21
  • 21
2
votes
3 answers

Displaying a decimal value on a windows form

I need help with displaying a decimal value on a Windows Form. I have a class with a method to calculate an interest amount, listed below. public virtual decimal CalculateInterest() { interest = (interestRate/100) * base.getBalance(); return…
Susan