473,396 Members | 1,970 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,396 software developers and data experts.

Silent truncation of numeric values.


Hi,

How come numeric(10,2) accepting value 10.011 and truncating the .001
part ? Shudnt' it be complaining , i am not sure.
Regds
Mallah.
tradein_clients=# CREATE TABLE t_a ( a numeric (10,2) );
CREATE TABLE
tradein_clients=#
tradein_clients=#
tradein_clients=# \d t_a
Table "public.t_a"
Column | Type | Modifiers
--------+---------------+-----------
a | numeric(10,2) |

tradein_clients=# INSERT INTO t_a values(10.01);
INSERT 50817524 1
tradein_clients=# INSERT INTO t_a values(10.011);
INSERT 50817525 1
tradein_clients=#
tradein_clients=#
tradein_clients=# SELECT * from t_a;
a
-------
10.01
10.01
(2 rows)

tradein_clients=#
Nov 12 '05 #1
1 1649

On Sat, 22 Nov 2003, Rajesh Kumar Mallah wrote:
How come numeric(10,2) accepting value 10.011 and truncating the .001
part ? Shudnt' it be complaining , i am not sure.


AFAICS, the spec says that implementation-defined rounding or truncation
occurs if least significant digits would be lost. It appears to only be
an error if most significant digits would be lost.

For example:
If an assignment would result in a loss of the most significant digits,
an exception condition is raised. If least significant digits are lost,
implementation-defined rounding or truncating occurs with no exception
condition being raised.

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #2

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

Similar topics

0
by: PiErre | last post by:
Hi, I used to install python 2.2 with the option /s (silent) on win2k server. Now I migrated to python 2.3 (Python-2.3.4.exe) and it seems to me that in all the registry values the drive is...
0
by: JezB | last post by:
I want to compare two DateTime values but only down to seconds, so how do I truncate DateTime values to second granularity ? Similarly, I may want to truncate to the minute granularity. I also may...
3
by: success_ny | last post by:
Does anyone have a code snippet to compare those values so I can sort the array of alpha-numeric values that include both characters and integers in it? I.e., if we have values like 4236 and...
26
by: Alfonso Morra | last post by:
Hi, I'm getting a compiler error of "pointer truncation from 'void *' to 'int'" because I'm not explicitly casting from void* to (datatype*). Pointers are stored as ints (is that right?), so as...
6
by: M.A. Oude Kotte | last post by:
Hi All, I hope this is the correct mailing list for this question. But neither postgresql.org nor google could help me out on this subject. I did find one disturbing topic on the mailing list...
7
by: Sheldon | last post by:
Hi, I have the following loop that I think can be written to run faster in Numeric. I am currently using Numeric. range_va = main.xsize= 600 main.ysize= 600 #msgva is an (600x600) Numeric...
1
by: Serman D. | last post by:
Background: The Payment Card Industry (PCI) Data Security Standard (PCI DSS) is a standard for financial institutions. It requires sensitive information, such as credit card numbers, to be...
112
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions...
13
by: chromis | last post by:
Hi, I have a query which updates the projects table of my database, however when I try to run my query with blank values i get the following error: Data truncation: Data truncated for column...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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,...

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.