decimal

How do I compare two decimals to 10 decimal places?

I'm using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0.1123456789 0.11234567891 0.11234567899 The 10 decimal limit is coming from my database, so I have to assume that the first number was al...

Converting representation from decimal to floating point numbers - pitfalls

I'm working on some functionality in a financial application. All numbers are represented as decimals without rounding errors both in the code and in the database. However, I'm having some performance problems and I'm considering switching to floating point numbers (float/double) in my own computations. This is based on the assumption th...

convert decimal to hex python

Hi All, Im building a server in python, i need to convert a decimal value to hex like this : let's say the packet start by 4 bytes which define the packet lenght : 00 00 00 00 if the len(packet) = 255 we would send : 00 00 00 ff Now my problem is that sometimes the packet is bigger than 256 as for example 336, then it would be : 00 00...

C# : Check value stored inside string object is decimal or not

in C# , how can i check whether the value stored inside a string object( Ex : string strOrderId="435242A") is decimal or not? ...

Hex 0x0001 vs 0x00000001

hi, often in code that uses permissions checking, i see some folks use hex 0x0001 and others use 0x00000001. these both look like an equivalent of a decimal 1, if i'm not mistaking. why use one over the other, just a matter of preference? ...

How can a float representation be off 1 from a decimal representation in perl?

I ran across an interesting issue in some of my "humanize_bytes()" code. This loop represents the issue without all the other logic. The loop needs to stop when the bytes have been truncated to a "human readable" level. It keep iterating until the final value is less than 1024 (or specifiable bytesize). I started looking into the pro...

SQL Decimal Issue

I have an input string in the following format: 12.34 When I call this line: db.AddInParameter(insertMessageDetailCommand, "AttachmentSize", System.Data.SqlDbType.Decimal , Convert.ToDecimal(this.messageEnvelope.EnvelopeInfo.AttachmentSize)); I get an input string not in the correct format. The server I am deploying to have regional...

Why does the balance become 1.00 whenever the sql command below is executed no matter what value of $cost is?

Why does the balance become 1.00 whenever the sql command below is executed no matter what value of $cost is? update account set balance=balance-'$cost' and username='steven'" The value of balance is bigger than $cost initially, after the execution, the balance of 'steven' becomes 1.00. What's wrong? Say, when the initial balance is...

How to calculate difference in hours (decimal) between two dates in SQL Server?

I have to calculate the difference in hours (decimal type) between two dates in SQL Server 2008. I couldn't find any useful technique to convert datetime to decimal with 'CONVERT' on MSDN. Can anybody help me with that? UPDATE: To be clear, I need the fractional part as well (thus decimal type). So from 9:00 to 10:30 it should return m...

Decimal Cut problem

Is it possible to cut decimal, and not round it. Like this. decimal number = 12.159m; How can I easily get 12.15 from number and not 12.16? Is there an easy way or is the string manipulation the only way? ...

Format decimal for percentage values?

What I want is something like this: String.Format("Value: {0:%%}.", 0.8526) Where %% is that format provider or whatever I am looking for. Should result: Value: %85.26.. I basically need it for wpf binding, but first let's solve the general formatting issue: <TextBlock Text="{Binding Percent, StringFormat=%%}" /> ...

ODP ADO.NET driver returns decimal with extra zero in string representation

Hello, Today's problem is as follows: we have a table in an Oracle database. The table contains a field that is of the type Number(18, 3). On the surface, both saving and loading data from said field work perfectly. However, further inspection reveals, that numbers that have three decimal digits in them, e.g. 500.001, are read from the...

What does M,D mean in decimal(M,D) exactly?

Does anyone know about this? ...

Question on converting decimal to binary to hex

I'm a little confused here: I'm trying to reverse engineer the ASCII value 65. In the book I am reading it says: Decimal: 65 Hex: 41 Octal: 101 But 65 in its binary representation is: 0010 0001 And 0010 in hex is 2, while 0001 is 1, which indicates that the hex value "should" be: 21. Where did I go wrong? ...

Drop 0 value in decimal places

Hi, I want to ask if anybody know the query to drop the 0 value in decimal.. E.g : A field name percent have these values Percent 770.00000000000000000000, 340.670000000000000000000, 96.00000000000000000000, 4400.56000000000000000000, 109.89000000000000000000, 109.00000000000000000000, 37.00000000000000000000, Currently I'm using th...

DECIMAL vs INT what is the best optimized choice?

I'm sure this ask in incomplete without a precise context, so I'll try to explain it, and I'll try to be clear I need to store a whole of data rapresented on the page with grams, milligrams, micrograms and kilojoule. All of this data is like 99999.99g (kilojoule apart), so I could use DECIMAL(7,2) or DECIMAL(5,2) with older MySql versio...

Using PHP to Convert ASCII Character to Decimal Equivalent

Can someone suggest a (preferably) graceful way to convert an ASCII character to its decimal equivalent using PHP? ...

C# decimal tostring format

Hello, I want to create a string from a decimal, whithout the decimal separator; 1,500.00 should become "150000". What is the proper format for this? (Whithout string.replace , and .) Thank you! ...

show decimal or double with zeros

hi i get price values from DB. now whenever the price is perhaps 5, I want to show 5.00 if its 4.3 it should be 4.30. how to convert that? thanks ...

DataGridView decimal value formatting: kosher way.

Hi, I need to display decimal values in DataGridView if (dgvClients.SelectedRows.Count != 0) { DataGridViewRow row = dgvClients.SelectedRows[0]; row.Cells["NetAccountValue"].Value = info.DecimalValue; } I need to format value up to given digits after decimal separator. The problem is ...