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

Rounding Problem in Stored Functions

1
Hi Friends

I am having trouble with a function Round.This function returns different values in different scenarios.
This is what happens when value was directly passed

Query goes as follows

* Passing Value directly

zint numeric(12,0);

zint := Round((3000.00 / 1200),0);
return zint ;
end;'

Above Func return value 2 in zint

This is what happens when value is passed through a variable.
*Passing it through Variable.

Query goes as follows

zint numeric(12,0);
zproduct numeric(12,0);
begin
zproduct:=1000;
zproduct:=(zproduct * 3)/1200;
zint := Round(zproduct);
return zint ;
end;'

Above Func return value 3 in zint

Can anyone help me to know the difference between the two query?
Jan 19 '08 #1
1 2782
rski
700 Expert 512MB
Hi Friends

I am having trouble with a function Round.This function returns different values in different scenarios.
This is what happens when value was directly passed

Query goes as follows

* Passing Value directly

zint numeric(12,0);

zint := Round((3000.00 / 1200),0);
return zint ;
end;'

Above Func return value 2 in zint

This is what happens when value is passed through a variable.
*Passing it through Variable.

Query goes as follows

zint numeric(12,0);
zproduct numeric(12,0);
begin
zproduct:=1000;
zproduct:=(zproduct * 3)/1200;
zint := Round(zproduct);
return zint ;
end;'

Above Func return value 3 in zint

Can anyone help me to know the difference between the two query?
What postgres do you use? It works fine for me, the first function return 3 I've tested it.
Jan 21 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Danny Woolston | last post by:
Hi I have a double that i want to round to a certain number of decimal places this is the code i use Return Math.Round(mdNumber, mbDecimalPlaces) mbDecimalPlaces is the number of decimal...
14
by: calan | last post by:
Does anyone have a function that will round a number to 0 or .5? I have a form where I'm entering a number in inches. I need to round it to the nearest 1/2 inch (onChange). The split will be...
3
by: Caesar Augustus | last post by:
Hello Tom, Long time listener, first time caller... I have been working with vb code to automate a salary increase process that not only rounds to the nearest penny but also rounds to the...
4
by: spebola | last post by:
I am using vb.net 2003 professional and I get the following results when using the round method: dim Amount as decimal = 180.255 Amount = Amount.Round(Amount, 2) Amount now contains 180.25. ...
5
by: Jason | last post by:
I am having a rounding problem in a value i am trying to display in VB.NET. If I have the following code: Dim x As Single = 2726.795 Dim y As Single = Math.Round(2726.795, 2) Dim s as String =...
5
by: Cygnus | last post by:
Sorry in advance for the lack of formatting in this posting. Data: (column headers) Net Sales | Royalty Rate | Total Royalty (data) 4.31 | 50.00% | 2.15 19.35 | 50.00% | 9.68
29
by: Marco | last post by:
Hello, I have : float f = 36.09999999; When I do : char cf; sprintf(cf,"%0.03lf", f); I get : 36.100
6
by: abcd | last post by:
I am trying to write a rounding function. Rounding to 0.05. e.g. I should get below results 6.125 --6.15 1.699 --1.7 1.1985 --1.20 0.5625 --0.60 Can someone have any sample for...
206
by: md | last post by:
Hi Does any body know, how to round a double value with a specific number of digits after the decimal points? A function like this: RoundMyDouble (double &value, short numberOfPrecisions) ...
20
by: jacob navia | last post by:
Hi "How can I round a number to x decimal places" ? This question keeps appearing. I would propose the following solution #include <float.h> #include <math.h>
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
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...

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.