473,416 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

accounting apps, use Decimal, Int, or Double ?

keywords: mysql accounting currency decimal fixed "floating point"

Quoting the manual:
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
If D is omitted, the default is 0. If M is omitted, the default is 10.
All basic calculations (+, -, *, /) with DECIMAL columns are done with
a precision of 64 decimal digits.

Re: Floating Point limitations and using IEEE format floating point
many numbers cannot be stored exactly in a FP format
FP inaccuracies are bound to cause error and worry. round() has its
own problems.
Should I use
* double and also use round()
or
* int (storing in $ .01 ) and then format for all displays, and
reports

Anyone have personal experience or solutions for this problem ? TIA

Nov 28 '05 #1
1 3670
>keywords: mysql accounting currency decimal fixed "floating point"

Quoting the manual:
DECIMAL[(M[,D])] [UNSIGNED] [ZEROFILL]
If D is omitted, the default is 0. If M is omitted, the default is 10.
All basic calculations (+, -, *, /) with DECIMAL columns are done with
a precision of 64 decimal digits.

Re: Floating Point limitations and using IEEE format floating point
many numbers cannot be stored exactly in a FP format
FP inaccuracies are bound to cause error and worry. round() has its
own problems.
Should I use
* double and also use round()
or
* int (storing in $ .01 ) and then format for all displays, and
reports


There is no exact representation for 0.01 in binary floating point.
You're just begging for rounding errors if you use quantities of
dollars in a floating point variable.

I prefer to use integer quantities of *cents* (or the smallest unit
of whatever currency you are using). The logical C types to use
are long, long long, double, or long double. Check before proceeding
whether you have enough range. A 32-bit long, for example, can
cover about +/- $20 million, which may be enough for most individuals
(even when calculating lifetime earnings). A 64-bit long long might
even cover 100 years of the Bush (A thru Y) administrations military
spending.

You need special currency formatting routines. You may want them
*anyway*: it is common to represent negative numbers in
ways unusual to math, such as:
100.00-
or (100.00)

Regardless of whether you use decimal in MySQL, you may not have
it available outside of MySQL, so either you'll need to do all
your calculations in MySQL, or worry about representing it outside
MySQL.

Gordon L. Burditt
Nov 28 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andreas Pauley | last post by:
Hi All, Our company is currently evaluating Python as a language for writing financial/accounting type software (among others). What libraries or packages are available in this domain for use?...
17
by: John Bentley | last post by:
John Bentley: INTRO The phrase "decimal number" within a programming context is ambiguous. It could refer to the decimal datatype or the related but separate concept of a generic decimal number....
41
by: Matt Alanzo | last post by:
Our SOHO 2 person compay sells furniture (not programmers). In '98 we paid $,$$$ for a VBA -Access '97 accounting application, including VBA source code .... an huge investment for us then (and...
4
by: Ron | last post by:
Greetings, int i = 1, j = 6; double k = (double)i/j; Console.WriteLine(k.ToString()); Console.WriteLine(string.Format(k.ToString(), "0.00")); both yield 0.166666666666667 how can I make...
10
by: Paul Sullivan | last post by:
decimal d; d = 1.1M OR d= (decimal) 1.1 Discussioon
4
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi everyone! I'm using greece - greek in my control panel's regional options, and so, my decimal point is the comma (,), while it is the dot (.) for the sql server db, however, I'm facing...
12
by: ThunderMusic | last post by:
Hi, We have a part of our application that deals with millions of records and do some processing of them. We've achieved a pretty good performance gain by developping a custom DateTime.ToString...
13
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, Why does Math.Sqrt() only accept a double as a parameter? I would think it would be just as happy with a decimal (or int, or float, or ....). I can easily convert back and forth, but I am...
10
by: Jason | last post by:
I'm making a program that will convert decimal inputs (in this case, in inches) and output a fractional answer. At the moment, I'm only able to output the fractional answer in three parts: A whole...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.