decimal

How to name functions to extract parts of a decimal number?

I am writing a class for handling decimal numbers, e.g. "123.456". I want one function for extracting the digits before the decimal point (123), and one function to extract the digits after the decimal point (0.456). My question is not how to do the programming, but how to name the functions? Do you have any better idea than digits_befor...

Extracting numerical value from Python Decimal

When I use the python Decimal object simply with something like: from decimal import * dec = Decimal('3.432') print dec it will print 3.432, just like I want, but if i try to put that same value dec into a json object what I get in the json is Decimal("3.432"). How can I just get the numerical value from decimal? ...

Will PHP DateInterval support decimals to add to a date/time?

According to wikipedia - en.wikipedia.org/wiki/ISO_8601 , it should be possible to do this (assuming PHP supports the full ISO 8601): $date = new DateTime(date('Y-m-d H:i:s', time())); // current time - create date time object date_add($date, new DateInterval("PT".round(2.5,2)."H")); //add 2.5 hours (throws exception unknown or bad form...

How do I determine the number of places following a decimal in a floating point value?

In C++ you can use std::numeric_limits<FloatingPointType>::digits10 to find out exactly how many places of precision you can get before the decimal place. How do I find out how many decimal places I can get following it, if I know the number will always be fixed-point between 0 and 1 inclusive? Edit: The reason I ask is that I have an...

Is SQL Server 'MONEY' data type a decimal floating point or binary floating point?

I couldn't find anything that rejects or confirms whether SQL Server 'MONEY' data type is a decimal floating point or binary floating point. In the description it says that MONEY type range is from -2^63 to 2^63 - 1 so this kind of implies that it should be a binary floating point. But on this page it lists MONEY as "exact" numeric. Wh...

Decimal point in calculator c#

AHHHHH ok this is driving me nuts. Why when does my decimal point in the wrong place e.g. if i have the string 567 in the textbox and click the decimal button i would expect (or i want) the textbox to change to 567. but instead i get .567 It only goes into the correct place when i add another number e.g. if i had the number 4 then st...

decimal.ToString("C")

Hi, I have a problem with decimal.ToString("C") override. Basically what I wants to do is as follows: CultureInfo usCulture = new CultureInfo("en-US"); Thread.CurrentThread.CurrentCulture = usCulture; NumberFormatInfo LocalFormat = (NumberFormatInfo)NumberFormatInfo.CurrentInfo.Clone(); LocalFormat.CurrencySymbol = "RM"; I wants to m...

How to configure Visual Studio to show integers as decimals when debugging?

My Visual Studio 2008 debugger is showing integers as hexadecimals, how to correct that? ...

Converting this varchar to a decimal with the appropriate decimal point?

Hi everyone, I've been playing with cast()s and such with this and can't seem to get things to work. I have a varchar string that's 18 characters long that I'd like to convert or cast to a decimal, with five decimal places. So for instance, this string: 00000001987600130 Would become 19876.00130 It's the case that I'll always have ...

Regex for decimal numbers

Could anybody provide a regular expression for a number that has to be between 1 and 17 in length, and could optionally contain a mantissa of up to 4 places? The length of 17 includes both the characteristic and the mantissa. Edit: The length of 17 excludes the decimal point. Valid examples: 12345678901234567 1234567890123.4567 ...

ARM assembly print register value in decimal

Hey, I have an exponentiation subroutine that does the calculation and puts the result in r0. Currently I can print the result in hexadecimal, but I also want to print it in decimal. After doing a lot of searching online I haven't found a straightforward way of doing it. Seems like a simple task to do but I can't figure it out. thanks ...

Doing a Math.Round(x,2) on a decimal value, but need to ensure 2 numbers after decimal as its money

Some values are returning 2.0 but I need it to be 2.00 as this is a money value that is displayed to the web page. I am doing: Math.Round(value, 2); Is there a way to force it to 2 numbers after the decimal? ...

How do I interpret precision and scale of a number in a database?

I have the following column specified in a database: decimal(5,2) How does one interpret this? According to the properties on the column as viewed in SQL Server Management studio I can see that it means: decimal(Numeric precision, Numeric scale). What do precision and scale mean in real terms? It would be easy to interpret this as a ...

How to cut a mpz_t into two parts using GMP lib on C?

Using GMP on c, I have a big integer "mpz_t n" in decimal form, how can I cut it into 2 parts? In fact, these 2 parts should have the same length in binary. For example, maybe I can convert the n to a binary of 112bits, then I want to cut it into 2 56bits parts. Thanks ...

Using C++ hex and cin

If you have the following code: cout << hex << 10; The output is 'a', which means the decimal 10 is converted into its hexadecimal value. However, in the code below... int n; cin >> hex >> n; cout << n << endl; When input is 12, the output becomes 18. Can anyone explain the details of the conversion? How did it became a decimal va...

Convert percent value to decimal value in PHP

Hello, How to convert percent value to decimal value in PHP to be used in a computation? Example: 6.15% = .0615 Thanks! ...

Python Decimals format

WHat is a good way to format a python decimal like this way? 1.00 --> '1' 1.20 --> '1.2' 1.23 --> '1.23' 1.234 --> '1.23' 1.2345 --> '1.23' ...

building decnumber++ in visual studio

hi there, i'm getting errors when trying to build the decnumber++ library in vs2008. the error i'm getting is C2995 and C2666. to me it seems visual studio is not allowing template function overloading? if anyone has any ideas i would really love to hear them. if anyone would like to try and build this decimal library in VS to see if th...

Test if value is Decimal

In some Python (v3) code I am creating lists of Decimals from user input, like this: input = [] # later populated with strings by user with values like '1.45984000E+001' decimals = [Decimal(c) for c in input] However, sometimes the input list contains strings that cannot be parsed. How can I test if c can be represented as a decimal b...

Converting to Base 10

Question Let's say I have a string or array which represents a number in base N, N>1, where N is a power of 2. Assume the number being represented is larger than the system can handle as an actual number (an int or a double etc). How can I convert that to a decimal string? I'm open to a solution for any base N which satisfies the abov...