decimal

MS Access Typecasting Number to Double

I've got a MS Access 2007 DB with records of passed and failed attempts to pass an exam. Student_id, Course_id, passed S001 C001 0 S001 C001 1 S002 C001 1 S003 C001 0 'Passed' is used as a boolean where 0 is failed an 1 passed, but is stored as a number. I want to build a query dis...

Creating image or graphic in C# from decimal data?

Is it possible to create an image or graphic using vector data that has decimal components that vary? And, of course, if its possible... then how? For example: a vector has two points where point one is {9.56, 4.1} and point two is {3.456789,2.12345}. Note: the precision varies from number to number. ...

Regular Expression issue.

I have an issue regarding the use of the following regular expression: private Regex _regexDecimals = new Regex(@"[^.,0-9]"); when I use above the result is dat I can use 1 0,5 ,5 1.0 but when I enter .5 it results in an error trying it to convert it to a double. Now I've made the following regular expression: private Regex _regex...

C++ convert decimal hours into hours, minutes, and seconds

I have some number of miles and a speed in MPH that I have converted into the number of hours it takes to travel that distance at that speed. Now I need to convert this decimal number into hours, minutes, and seconds. How do I do this? My best guess right now is: double time = distance / speed; int hours = time; // double to integer con...

Oracle number to C# decimal

Hi! I know there are several threads and posts regarding this issue in the internet and I've read them (not every article, I have to admit) but none of them did fully satisfy me. My situation: I'm using ODP.net (dll version 2.111.6.0) to access the Oracle DB (version 10 + 11) and a DataReader to retrieve the data (.NET 3.5, C#). Using...

Reason to use DECIMAL(31,0)

What is the reason that some people from Oracle background are using DECIMAL(31,0) for integers. In MySQL it is not efficient. ...

LINQ to SQL sum of decimal values

I can't figure out how to do a simple sum of decimal values. Table<StaffTime> times = ctx.GetTable<StaffTime>(); var query = from t in times select new { t.Hours.Sum() } Isn't Sum an extension method? What am I missing? Bob ...

PHP convert decimal into fraction and back?

I want the user to be able to type in a fraction like: 1/2 2 1/4 3 And convert it into its corresponding decimal, to be saved in MySQL, that way I can order by it and do other comparisons to it. But I need to be able to convert the decimal back to a fraction when showing to the user so basically i need a function that will conver...

WPF C# string to decimal, decimal to string problem

Please, help me to identify problem in my C# code(WPF, event-handler): private void Discount5Btn_Click(object sender, RoutedEventArgs e) { decimal catPr; decimal salePr; string catPrStr; catPrStr = PriceCatTBox.Text; catPr = decimal.Parse(catPrStr); salePr = decimal.Multiply(ca...

Check if a binary number has a '0' or a '1' at a specific position

Hi I'd like to check if a binary number has a '0' or a '1' at a specific position. example: if the binary number is: 101000100 checking at position zero (that is at the rightmost '0') should result in '0'. checking at position 2 should result in '1'. checking at position 3 should result in '0'. checking at position 6 should result i...

iPhone Currency input using NSDecimal instead of float

Hello, iPhone/Objective-C/Cocoa newbie here. Based on a number of posts on stackoverflow, I have cobbled together an IBAction that I'm using in a basic iPhone calculator app that I'm building. The IBAction works with the numeric keypad to allow entry of decimal numbers without having to enter a decimal point. I am trying very hard to ...

mysql query adding to a decimal doubles value of the addend for some reason

I am trying to add a value ($credit) to the value of a decimal (9,2 max length) field in a mysql database. The problem is that when I do this, it doubles the $credit and then adds it for some reason. I just want it to add it. The code I am using is: mysql_query("update $table set earnings = earnings +$credit where username = ('$member')...

MS Calculator on windows 7. I need to know how it does its operations.

MS calculator on windows 7 has a "programmers" mode. When I type in (in binary): 1111111111111111111111111111111111111111111111111111111111111111 and then click "Dec", the binary turns into -1. When I click Oct, the value turns into 1777777777777777777777 However, whenever I use an online converter, it doesn't work. I need to know ho...

Django: How should I store a money value?

I'm running into a paradigm problem here. I don't know whether I should store money as a Decimal(), or if I should store it as a string and convert it to a decimal myself. My reasoning is this: PayPal requires 2 decimal places, so if I have a product that is 49 dollars even, PayPal wants to see 49.00 come across the wire. Django's Decim...

Python/Django: If 5 and 5.00 are different values (when expressed in Decimal), then...

If 5 and 5.00 and 5.000 are all different, then why does Django's decimal field save without the .00 even when I have decimal_places=2 ? More importantly, how can I save a value 5.00 as 5.00 in Django without using String. ...

Store and return decimals with user-entered precision in SQL Server

Does the SQL Server decimal data type stored the actual number of digits after the decimal for each value in a column? For example UPDATE [Mixes] SET [Concentration] = 0.0012500 WHERE [Id] = 1 where Concentration Decimal(21,11) Is it possible to retrieve the exact "0.0012500" value as entered by the user, or is it necessary to st...

Fractions with decimal precision

Is there a pure python implementation of fractions.Fraction that supports longs as numerator and denominator? Unfortunately, exponentiation appears to be coded in to return a float (ack!!!), which should at least support using decimal.Decimal. If there isn't, I suppose I can probably make a copy of the library and try to replace occurre...

From textbox to decimal value then into access database in c#

I'm reading a decimal value from textbox1 and need to insert it to an decimal field in my database. I having a trouble with "," and "." so first I'm replacing ","s with "." But unfortunately If I enter 1.34 in textbox, it becomes 134.00 in db. string text = textBox1.Text; text = text.Replace(",", "."); decimal total = decimal.Parse(te...

Subclassing Decimal in Python

I want to use Decimal class in my Python program for doing financial calculations. Decimals to not work with floats - they need explicit conversion to strings first. So i decided to subclass Decimal to be able to work with floats without explicit conversions. m_Decimal.py: # -*- coding: utf-8 -*- import decimal Decimal = decimal.Decim...

A question for you who work with hexadecimal frequently

Hello, Whenever I work with hexadecimal values, I do the conversion (if needed) into decimal in my head or with the help of a converter. Well I was thinking, if you work long enough and get used to hexadecimal, do you just 'see' the value (whatever that means), as when reading decimal ? I mean are you after a while able to read base 16 ...