Wortz, Charles
CWortz at tea.state.tx.us
Tue Apr 8 07:41:56 CDT 2003
Pedro, You seem to have a misconception of how computers work. They are binary (base 2) not decimal (base 10). Thus numbers can only be represented as the sum of powers of two. Since all integers (numbers without fractional parts) can be represented exactly as the sum of powers of two they can be stored and manipulated without any loss of precision (excepting division operations). All floating point numbers (numbers with fractional parts), except for those rare ones where the fractional part is an exact sum of powers of two, must be represented by an approximation of its value. The precision of a floating point number tell you how close to actual value the approximate value can come. Thus for Singles with about seven digits of precision, you know that up to the seventh digit accurately represent the actual value and any digits beyond that should not be counted on to be accurate. Thus you must choose between the exact representation of integers and the approximate representation of floating point numbers. In later versions of VB and other languages there is now a third choice, the currency datatype. This is a compromise between the two fundamental numeric datatypes. It is a scaled integer used to represent floating point numbers where you do not want more than four digits of precision for the fractional part. To get what you want, you must pick from these numeric datatypes and then use the proper rounding and formatting functions to get the numbers to display as you desire. There are no other choices if you are going to do it on a computer. Charles Wortz Software Development Division Texas Education Agency 1701 N. Congress Ave Austin, TX 78701-1494 512-463-9493 CWortz at tea.state.tx.us -----Original Message----- From: Pedro Janssen [mailto:pedro at plex.nl] Sent: Tuesday 2003 Apr 08 06:17 To: accessd at databaseadvisors.com Subject: Re: [AccessD] roundup - decimal places Hello Charlotte, i want truly round numbers with 1 precision. Pedro Janssen ----- Original Message ----- From: Charlotte Foust <mailto:cfoust at infostatsystems.com> To: accessd at databaseadvisors.com Sent: Monday, April 07, 2003 7:41 PM Subject: RE: [AccessD] roundup - decimal places You're going to have to explain whether you want to truly round numbers or just display them that way. The Decimal places setting addresses the display, not the precision. Charlotte Foust -----Original Message----- From: Pedro Janssen [mailto:pedro at plex.nl] Sent: Monday, April 07, 2003 9:25 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] roundup - decimal places Hello Charles, when i type 5,1 i type 5,1 and not . How does a computer changes 5,1 into 5,11415899 although i type 5,1. What is the use of decimal places:1, with field size: single, when the pc makes a lott of decimal places from it. Then this property better wasn't available when using numbers (not currency). Is there a way to roundup the numbers to 1decimal place without using currency. Pedro Janssen ----- Original Message ----- From: Wortz, Charles <mailto:CWortz at tea.state.tx.us> To: accessd at databaseadvisors.com Sent: Monday, April 07, 2003 5:42 PM Subject: RE: [AccessD] roundup - decimal places Pedro, Remember, you are working on a binary computer. Thus decimal numbers must be approximated as the sum of powers of two. For integer numbers these approximations are exact representations. For floating point numbers, these approximations are just that - approximations. None of your floating point numbers are stored with just one digit to the right of the decimal point, they are only displayed to you as such. If you cannot learn to live with floating point numbers, then convert them to the currency datatype. The currency datatype will meet many of you computational needs. Charles Wortz -----Original Message----- From: Pedro Janssen [mailto:pedro at plex.nl] Sent: Monday 2003 Apr 07 10:30 To: AccessD at databaseadvisors.com Subject: [AccessD] roundup - decimal places Hello Group, i have a tableA with 5 fields (field size: single, decimal places:1) Not all fields have values. I want the difference from al those field, so i added a field diff. I made an update query with the following sql: UPDATE TableA SET TableA.[diff] = 100-Nz([field1],0)-Nz([[field2],0)- etc. etc.; The result that i get in field diff gives many records with more then 1 decimal places. For example: When i have a record which contains values like 5,1 and 94,9 (all values are typed in this way and are not calculated) i get as result 0,11176548 or a record that contains values like 20,5 and 20,5 i get as result 59,997854. Some result do have only one decimal place. How is this possible? TIA Pedro Janssen -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030408/072c7e9b/attachment-0001.html>