I've a SQL view performing a number of very precise calculations ie.
495/(1.112 - (.00043499*((Co l1 + Col2 + Col3))) + ( .00000055 * ((Col1
+ Col2 + Col3)) * ((Col1 + Col2 + Col3))) - (.00028826 * Col4))) -
450)/100
Obviously this sometimes causes a precision issues because the float
and real datatypes don't hold precise values... My problem is that
converting to the numeric or decimal datatype easily produces an error
if the precision is not big enough to hold the resulting output... So
here's my questions:
Does anyone see a problem with me maxing out the precision of the
decimal datatype (ie. use DECIMAL(38,8) across a couple dozen
inter-related formulas?
So the above code would now exec like this:
495/(CONVERT(DECIMA L(38,8),1.112) -
(CONVERT(DECIMA L(38,8),.000434 99)*((Col1 + Col2 + Col3))) +
(CONVERT(DECIMA L(38,8),.000000 55) * ((Col1 + Col2 + Col3)) * ((Col1 +
Col2 + Col3))) - (CONVERT(DECIMA L(38,8),.000288 26) * Col4))) - 450)/100
If anyone does see a problem with this approach, could you suggest
another alternative? 1 3559
Tariq (ta***@inwebcom .com) writes: I've a SQL view performing a number of very precise calculations ie.
495/(1.112 - (.00043499*((Co l1 + Col2 + Col3))) + ( .00000055 * ((Col1 + Col2 + Col3)) * ((Col1 + Col2 + Col3))) - (.00028826 * Col4))) - 450)/100
Obviously this sometimes causes a precision issues because the float and real datatypes don't hold precise values... My problem is that converting to the numeric or decimal datatype easily produces an error if the precision is not big enough to hold the resulting output... So here's my questions:
Does anyone see a problem with me maxing out the precision of the decimal datatype (ie. use DECIMAL(38,8) across a couple dozen inter-related formulas?
I may be missing something, but 495 / <some basically arbitrary number>
will not be a decimal number, only a rational number. Unless you store
nominator and denominator separately, you will lose precision. With
float you will 14-16 digits of precision, which is good for many cases.
I don't really see what decimal(38,8) buys, although there is probably
not any major harm.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server SP3 at http://www.microsoft.com/sql/techinf...2000/books.asp This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ladvánszky Károly |
last post by:
Entering 3.4 in Python yields 3.3999999999999999.
I know it is due to the fact that 3.4 can not be precisely expressed by the
powers of 2. Can the float handling rules of the underlying layers be set
from Python so that 3.4 yield 3.4?
Thanks,
Károly
|
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 <size_t _decimal_places =...
|
by: Brian van den Broek |
last post by:
Hi all,
I guess it is more of a maths question than a programming one, but it
involves use of the decimal module, so here goes:
As a self-directed learning exercise I've been working on a script to
convert numbers to arbitrary bases. It aims to take any of whole
numbers (python ints, longs, or Decimals), rational numbers (n / m n,
m...
|
by: Madan |
last post by:
Hi all,
I had problem regarding float/double arithmetic only with + and -
operations, which gives inaccurate precisions. I would like to know how the
arithmetic operations are internally handled by C# or they are hardware
(processor) dependent. Basic addition operation errors, for ex:
3.6 - 2.4 = 1.19999999999 or 1.20000000003
There are the...
|
by: Karl O. Pinc |
last post by:
FYI,
It'd be nice if the error message from a REFERENCES
constraint mentioned the column name into which
the bad data was attempted to be inserted.
In PostgreSQL 7.3:
sandbox=> insert into foo (id, b) values (3, 2);
ERROR: b_is_fkey referential integrity violation - key referenced from
| |
by: Donkey |
last post by:
Hi,
The precision of built-in date type of C is very low. Even using long
double float type or double float type, we can only use 12 or 16 digits
after the decimal point. What can we do if we want to use
high-precision number such as the number with 50 digits after the
decimal point. Can we define a user date type?
|
by: Vamsi |
last post by:
Hi,
I have a column defined as decimal(4,3).
I get the following error when I try to insert "12.50000000000000"
CLI0111E Numeric value out of range. SQLSTATE=22003
sqlstate = 22003
I even tried with "12.500" and "12.50" , but still get the same error.
My point here is, it allows only one number before the decimal point.
|
by: Boot2TheHead |
last post by:
This one cost me a solid half hour yesterday. I'm wondering why on
earth the default precision for a decimal type is 18,0. Maybe I'm
mistaken. A decimal datatype sort of implies that you'd want something
after the decimal!
Question is, can I set this database-wide? Like all new decimal
datatypes have a precision of 12,6 or something like...
|
by: GCRhoads |
last post by:
I'm looking for a very basic high-precision arithmetic library. I
need to be able to specify a fixed number of bits or decimal digits
(32 decimal digits should be all I need). The only arithmetic
functions I need are addition, subtraction, multiplication, division,
square-root, and comparison (i.e. less-than, greater-than, equal)....
|
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, well explore What is ONU, What Is Router, ONU & Routers main...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
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...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |