decimal

C# Decimal datatype performance

I'm writing a financial application in C# where performance (i.e. speed) is critical. Because it's a financial app I have to use the Decimal datatype intensively. I've optimized the code as much as I could with the help of a profiler. Before using Decimal, everything was done with the Double datatype and the speed was several times fas...

SQL Server 2005 varchar loses decimal places converting to a decimal

Declare @BadDecimal varchar(5) Set @BadDecimal = '4.5' Declare @GoodDecimal Decimal Set @GoodDecimal = @BadDecimal Select @GoodDecimal --Outputs 5 Why? ...

How do I calculate percentages with decimals in SQL?

How can i convert this to a decimal in SQL? Below is the equation and i get the answer as 78 (integer) but the real answer is 78.6 (with a decimal) so i need to show this as otherwise the report wopnt tally up to 100% (100 * [TotalVisit1]/[TotalVisits]) AS Visit1percent ...

Raising a decimal to a power of decimal ?

The .net framework provides in the Math class a method for powering double. But by precision requirement I need to raise a decimal to a decimal power [ Pow(decimal a, decimal b) ]. Does the framework have such a function? Does anyone know of a library with this kind of function? ...

random Decimal in python

How can I get a random decimal.Decimal? it appears that the random module only returns floats which are a pita to convert to Decimals. ...

Write a number with two decimal places SQL server.

How do you write number in two decimal place for sql server? ...

Java code or lib to decode a binary-coded decimal (BCD) from a String

I have a string consisting of 1's ('\u0031') and 0's('\u0030') that represents a BCD value. Specifically, the string is 112 characters worth of 1's and 0's and I need to extract either 8 or 16 of these at a time and decode them from BCD to decimal. Ideas? Packages? Libs? Code? Snooty remarks about my sheer fucking laziness? All is welc...

Best Way to get Whole Number part of a Decimal Number

What is the best way to return the whole number part of a decimal (in c#)? (This has to work for very large numbers that may not fit into an int). GetIntPart(343564564.4342) >> 343564564 GetIntPart(-323489.32) >> -323489 GetIntPart(324) >> 324 The purpose of this is: I am inserting into a decimal (30,4) field in the db, and want to e...

numericUpDown problem...

Hi, I want to hide some things when the value of the numericUpDown is changed so I wrote this: if (numericUpDown1.Value = 1) { Label1.Hide(); } but I get this error message: Cannot implicitly convert type 'decimal' to 'bool' Thanks ...

Extract decimal part from a floating point number in C

How can we extract the decimal part of a floating point number and to store the decimal part and the integer part into seperate two integer variables? ...

use decimal values as attribute params in c# ?

I have been trying to use decimal values as params for a field attribute but i get a compiler error. I found this blog post link saying it wasn't possible in .Net to use then, does anybody know why they choose this or how can I use decimal params? Thanks. ...

add decimal as time

is there anyway to add a group of decimal numbers and excel treat it as time? example; 15.00 = 15 hours 1.00 = 1 hour .20 = 20 minutes .45 = 45 minutes .15 = 15 minutes excel adds this to 16.80, but if you want it as time the answer would be 17.15 17 hours 15 minutes ...

Generating a Random Decimal in C#

How can I get a random System.Decimal? System.Random doesn't support it directly. ...

How to Pass Decimal Value as Argument Correctly

I have this: double myDecimal = static_cast<double>(atoi(arg_vec[1])); cout << myDecimal << endl; But why when I pass the argument like this: ./MyCode 0.003 It prints 0 instead of 0.003. ...

In SQL how can I convert a money datatype to a decimal?

I want to convert a money datatype to a decimal, because I want to record the results to 8 decimal places. For example, in a currency rate table I see the rate stored as 2871047428.20 as a money datatype; using Microsoft SQL Management Studio, I want to divide that by 10000000 in order to achieve the result 287.10474282; however the res...

Formatting an SQL numeric query result with an arbitrary number of decimal places

I have a database table with these two columns: Amount: numeric (18,0) DecimalPlaces: numeric (18,0) This table can store amounts in various currencies, with the decimal place removed from the amount (I can't change this data model). For example, there might be two rows like this: 1290, 2 (This is £12.90, needs to appear as "12.90"...

Localization Problem Decimal Seperator

Is it possible that .NET uses on server A ',' as decimal seperator and on another server B '.'? + How can you detect this? When converting strings to doubles, on server A everything works fine, but on server B we have problems. Example: server A : 20,4 --> 20.4 server B : 20,4 --> 204 We would need to detect this so that on both serv...

XSLT Decimal formatting based on input XML.

I have a situation where my XSLT files should display prices alongwith decimals conditionally, depending on whether the input XML contains decimals or not. So, I can receive XML files with two types of values - XML will contain all prices formatted with decimals upto two places (I call this one "Decimal-XML") or the prices will be rounde...

C convert hex to decimal format

Hello, Compiling on linux using gcc. I would like to convert this to hex. 10 which would be a. I have managed to do this will the code below. unsigned int index = 10; char index_buff[5] = {0}; sprintf(index_buff, "0x%x", index); data_t.un32Index = port_buff; However, the problem is that I need to assign it to a structure and t...

Hex To String C#

Hello, I need to check for a string located inside a packet that I receive as byte array.If I use BitConverter.ToString() ,I get the bytes as String with dashes(example 00-50-25-40-A5-FF). I tried most function I found after a quick googling,but most of them have input parameter type string and if I call them with the string with dashes...