473,700 Members | 2,406 Online

# floating or decimal for currency values

hi

Isnt it true that floating type can generate rounding errors if the
values are rounded to like the 10th decimal. Since currency is rounded
only to the 2nd decimal why must i worry about using float for currency
calculations?

decimal is slow and memory hog.

is it true that mysql calculates internally using double float?

Andy

Jul 23 '05 #1
1 3852
<an****@verizon .net> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
hi

Isnt it true that floating type can generate rounding errors if the
values are rounded to like the 10th decimal.
Ti's true!
Floating point calculations *always* generate rounding errors. It's a
limitation we live with in order to gain the efficiency and large dynamic
range that floating point calculations offer.
Since currency is rounded
only to the 2nd decimal why must i worry about using float for currency
calculations?
Because chains of calculation and complex arithmetic (interest
calculations!) that we often use erodes that safety margin rather quickly.
AND many accounting apps. need that last penny accuracy. Even though
working with millions of \$ makes pennies seem insignificant - having things
work out to that last penny lends needed confidence to calculations. If you
are skimming the pennies into your personal account - use Float :-) If you
are looking for accounting accuracy, use Decimal.
decimal is slow Well - slower than float - perhaps!
and memory hog. Doubtful.
is it true that mysql calculates internally using double float?

I don't know!

Thomas Bartkus
Jul 23 '05 #2

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

### Similar topics

 5 12120 by: Ordz | last post by: I want to write a program that will take a decimal with up to 4 places and convert it to 1/16 ths. I can sort of do that with: n = 375 * 16 / 1000 Print n; "/16" I am planning to use an input box to enter the number with no decimal point. But I don't know how to get a count of the digits in the denominator. I will also round off any results that have a decimal place. I need 5 1784 by: j_mckitrick | last post by: I checked the docs, but found nothing about floating point issues. I am working on an app that deals with currency values, and only does addition and subtraction (no division). But I am starting to see values that should be the same failing a compare! What is the workaround or correct way to compare 2 floats? It worked fine for months, then suddenly starting acting odd. I might have upgraded Python somewhere in between, I can't... 4 7848 by: Roger Leigh | last post by: Hello, I'm writing a fixed-precision floating point class, based on the ideas in the example fixed_pt class in the "Practical C++ Programming" book by Steve Oualline (O' Reilly). This uses a long int to store the value, and the precision (number of decimal points) is variable (it's a templated class): template class FixedFloat { 687 23470 by: cody | last post by: no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't believe that. in pieces of the application where speed really matters you can still use "normal" functions or even static methods which is basically the same. in C there arent the simplest things present like constants, each struct and enum... 6 30028 by: Gilgamesh | last post by: Is decimal type a good choice to use for storing currency? I've got a situation that when I store 8.50 in a decimal type variable and read it back, I'm getting 8.5. Is there a better data type to store currency? Thanks, Gilgamesh 5 5428 by: VISHNU VARDHAN REDDY UNDYALA | last post by: Hello, Can someone over here help me in truncating a float variable. I mean if PI=3.14159 ...How can I get to read the first two or first three decimal values with out rounding them. Any suggestions are appreciated. I am BEGINNER TO C PROGRAAMING. Thanks 15 8055 by: Mukesh_Singh_Nick | last post by: Why does floating point have a rounding error? How to work around it? For example, the following: flaot f = 1234.12345678F; printf("%2f\n", f) //prints 1234.123413 and 2 1897 by: ArunDhaJ | last post by: Hi Friends, I am using a Number field which stored Floating point values... For example: Field Name: Salary Field Data Type: Number Field Size: Decimal Decimal place: 2 I need to get the data type of this field as Floating point or else as Decimal programmatically(in C or C++)... 2 1889 by: Rob Clewley | last post by: Dear Pythonistas, How many times have we seen posts recently along the lines of "why is it that 0.1 appears as 0.10000000000000001 in python?" that lead to posters being sent to the definition of the IEEE 754 standard and the decimal.py module? I am teaching an introductory numerical analysis class this fall, and I realized that the best way to teach this stuff is to be able to play with the representations directly, in particular to be... 0 8725 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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of... 0 9074 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is... 1 8970 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,... 0 8924 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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some... 0 7807 by: agi2029 | last post by: Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea... 1 6560 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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will... 0 5902 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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();... 0 4403 by: TSSRALBI | last post by: Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls... 0 4656 by: adsilva | last post by: A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.