473,508 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How many pre-decimal positions/integer digits has a DECimal (5,3) defined field ?

Does 5 represent the total numer of digits (including the fractional portion) or only the number of places
BEFORE the decimal point? Moreover does the number include the decimal point?

Are there differences between the databases servers ?

Peter

Jul 19 '05 #1
6 10522
pe****@gmx.net (Peter Blatt) wrote in message news:<ck*************@news.t-online.com>...
Does 5 represent the total numer of digits (including the fractional portion) or only the number of places
BEFORE the decimal point? Moreover does the number include the decimal point?

Are there differences between the databases servers ?

Peter

In Oracle, you would normally use the 'NUMBER(5,3)' declaration
instead of 'DECIMAL(5,3)'. It results in 5 digits being stored, with
the decimal place implied at position 3 - resulting in 6 'printer'
positions.

In Oracle, you can also specify 'NUMBER(5,-3)' which stores 5 digits
and puts the decimal 3 'zeros' after the last digit, giving you a
column or variable that displays 'thousands'.

Finally, in Oracle, the traditional internal representation of a
number is BCD - Binary Coded Decimal - with 2 digits per byte, up to
38 digits. Other variations, including IEEE Foating Point numerics
are possible as well.

If you need more details for the Oracle side, go to
http://docs.oracle.com for all online documentation, and look for the
SQL Reference Manual for the version(s) of interest. Excrutiating
detail is available in Chapter 1 under Datatypes.

Each RDBMS is exactly the same, only different. The 'only different'
is very subtle but significant enough that a generic application can
not swap out the back end without experienceing some negative impact -
frequently in scalability.

HTH
/Hans

BTW: comp.databases.oracle is a dead newsgroup, carried by only a few
ISPs. The question only needs to go to comp.database.oracle.misc (one
of the comp.databases.oracle.* heirarchy) as described in the Charter
available at http://orafaq.com
Jul 19 '05 #2
pe****@gmx.net (Peter Blatt) wrote in message news:<ck*************@news.t-online.com>...
Does 5 represent the total numer of digits (including the fractional portion) or only the number of places
BEFORE the decimal point? Moreover does the number include the decimal point?

Are there differences between the databases servers ?

Peter


This question is best asked in comp.databases which I added to the
list.
(but GOOGLE doesn't let me set the Follow-up: option)

IF you are asking about SQL databases, then the definition is
DECIMAL { (precision[,scale]) ]
where "precision is the total number of significant digits used to
express the number; the scale is the number of significant digits to
the right of the decimal point"

The quote is not directly from the standard. It's from SQL Instant
Reference published by SYBEX (C1993 so it is getting a little old).

For your last question, it seems database servers that claim to
support SQL would have to adhere to that definition.

HTH, both you and other readers.
Ed
Jul 19 '05 #3
pe****@gmx.net (Peter Blatt) wrote in message news:<ck*************@news.t-online.com>...
Does 5 represent the total numer of digits (including the fractional portion) or only the number of places
BEFORE the decimal point? Moreover does the number include the decimal point?

Are there differences between the databases servers ?

Peter


In Oracle:

5 represents total number of decimal digits, not including decimal point.
Jul 19 '05 #4
Alex Filonov wrote:
pe****@gmx.net (Peter Blatt) wrote in message
news:<ck*************@news.t-online.com>...
Does 5 represent the total numer of digits (including the fractional
portion) or only the number of places BEFORE the decimal point? Moreover
does the number include the decimal point?


According to the SQL standard (SQL99), subclause 4.5.1 (page 22) says:
-----------------
An exact numeric value has a precision and a scale. The precision is a
positive integer that determines the number of significant digits in a
particular radix (binary or decimal). The scale is a non-negative integer.
A scale of 0 (zero) indicates that the number is an integer. For a scale
of S, the exact numeric value is the integer value of the significant
digits multiplied by 10^(-s).
-----------------

That makes it absolutely clear that for SQL database systems the precision
(5 in the example above) is the total number of digits, including the
fractional portion and without the decimal character.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Jul 19 '05 #5
> Each RDBMS is exactly the same, only different. The 'only different'
is very subtle but significant enough that a generic application can
not swap out the back end without experienceing some negative impact -
frequently in scalability.
This is why I prefer NUMERIC instead of DECIMAL.

Per ANSI SQL, for DECIMAL, the RDBMS is allowed you to give you a higher precision than you asked
for. NUMERIC is required to give you the precision you ask for.

In SQL Server, they are the same (they both gives you exactly what you ask for). But by using
NUMERIC, I would have a consistent behavior across products (assuming the other product adheres to
the ANSI SQL standard).

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Hans" <fo******@gmail.com> wrote in message news:bd**************************@posting.google.c om... pe****@gmx.net (Peter Blatt) wrote in message news:<ck*************@news.t-online.com>...
Does 5 represent the total numer of digits (including the fractional portion) or only the number
of places
BEFORE the decimal point? Moreover does the number include the decimal point?

Are there differences between the databases servers ?

Peter

In Oracle, you would normally use the 'NUMBER(5,3)' declaration
instead of 'DECIMAL(5,3)'. It results in 5 digits being stored, with
the decimal place implied at position 3 - resulting in 6 'printer'
positions.

In Oracle, you can also specify 'NUMBER(5,-3)' which stores 5 digits
and puts the decimal 3 'zeros' after the last digit, giving you a
column or variable that displays 'thousands'.

Finally, in Oracle, the traditional internal representation of a
number is BCD - Binary Coded Decimal - with 2 digits per byte, up to
38 digits. Other variations, including IEEE Foating Point numerics
are possible as well.

If you need more details for the Oracle side, go to
http://docs.oracle.com for all online documentation, and look for the
SQL Reference Manual for the version(s) of interest. Excrutiating
detail is available in Chapter 1 under Datatypes.

Each RDBMS is exactly the same, only different. The 'only different'
is very subtle but significant enough that a generic application can
not swap out the back end without experienceing some negative impact -
frequently in scalability.

HTH
/Hans

BTW: comp.databases.oracle is a dead newsgroup, carried by only a few
ISPs. The question only needs to go to comp.database.oracle.misc (one
of the comp.databases.oracle.* heirarchy) as described in the Charter
available at http://orafaq.com

Jul 19 '05 #6
Yes, but page 125 states that for DECIMAL, the product can give you a higher precision than asked
for:

23) DECIMAL specifies the data type exact numeric, with the decimal scale specified by the <scale>

and the implementation-defined decimal precision equal to or greater than the value of the

specified <precision>.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Knut Stolze" <st****@de.ibm.com> wrote in message news:ck**********@fsuj29.rz.uni-jena.de...
Alex Filonov wrote:
pe****@gmx.net (Peter Blatt) wrote in message
news:<ck*************@news.t-online.com>...
Does 5 represent the total numer of digits (including the fractional
portion) or only the number of places BEFORE the decimal point? Moreover
does the number include the decimal point?


According to the SQL standard (SQL99), subclause 4.5.1 (page 22) says:
-----------------
An exact numeric value has a precision and a scale. The precision is a
positive integer that determines the number of significant digits in a
particular radix (binary or decimal). The scale is a non-negative integer.
A scale of 0 (zero) indicates that the number is an integer. For a scale
of S, the exact numeric value is the integer value of the significant
digits multiplied by 10^(-s).
-----------------

That makes it absolutely clear that for SQL database systems the precision
(5 in the example above) is the total number of digits, including the
fractional portion and without the decimal character.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena

Jul 19 '05 #7

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

Similar topics

21
10176
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default...
3
3769
Pre
by: Neal | last post by:
A few questions about pre... When presenting preformatted text using the white-space: pre; property/value, Opera renders long lines at small viewport widths as exiting the borders of the...
7
18513
by: Alan Illeman | last post by:
How do I set several different properties for PRE in a CSS stylesheet, rather than resorting to this: <BODY> <PRE STYLE="font-family:monospace; font-size:0.95em; width:40%; border:red 2px...
2
2774
by: Buck Turgidson | last post by:
I want to have a css with 2 PRE styles, one bold with large font, and another non-bold and smaller font. I am new to CSS (and not exactly an expert in HTML, for that matter). Is there a way to...
5
24083
by: Porthos | last post by:
I'm authoring an XML document and using the <pre> html tag for the portions that are not dynamically generated. The <pre> text is displaying in a smaller font size (and I believe different font)...
5
718
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
8
3768
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
7
2732
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
14
3603
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
0
7223
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
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7489
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
5624
agi2029
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,...
1
5047
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
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1547
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 ...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.