473,511 Members | 15,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Rounding Issues

4 New Member
Need Help! I am new to asp.net and I am having problems inserting proper data into SQL Server 2000. I have a field named salary with the datatype of decimal.

When I insert a value into the textbox (17.52) it rounds up (18) or down depending on value using bankers rounding. How do I get the 17.52 value inserted and retrieved into and from the database correctly. Do I have to do some special casting. I do not want to lose the cents neither up or down. Also, I tried using the currency datatype and it places 4 digits at the end of my number in the user interface. I only want to have it look like 17.52 not 17.5200.

I would appreciate any suggestions.

Thanks!
Jun 6 '07 #1
3 1336
Plater
7,872 Recognized Expert Expert
How did you declare your column?
Decimal(18,0) is equiv to an 18 digit integer
The format goes
Decimal( [total digits before and after the point], [max total digits after the decimal])

So if you wanted say money, you could use
Decimal(20,2) so you could have 18digits then a decimal point then 2 digits.

Try that?
Jun 6 '07 #2
mickeybaez
4 New Member
Need Help! I am new to asp.net and I am having problems inserting proper data into SQL Server 2000. I have a field named salary with the datatype of decimal.

When I insert a value into the textbox (17.52) it rounds up (18) or down depending on value using bankers rounding. How do I get the 17.52 value inserted and retrieved into and from the database correctly. Do I have to do some special casting. I do not want to lose the cents neither up or down. Also, I tried using the currency datatype and it places 4 digits at the end of my number in the user interface. I only want to have it look like 17.52 not 17.5200.

I would appreciate any suggestions.

Thanks!
I was able temporarily fix my problem by declaring the datatype as a float. I am able to see the proper formating in my grid as well as storing the proper number in my DB.

Thanks
Jun 7 '07 #3
mickeybaez
4 New Member
How did you declare your column?
Decimal(18,0) is equiv to an 18 digit integer
The format goes
Decimal( [total digits before and after the point], [max total digits after the decimal])

So if you wanted say money, you could use
Decimal(20,2) so you could have 18digits then a decimal point then 2 digits.

Try that?
Thanks for your help, I had it declared decimal (9,2) I fixed the problem by using the float datatype. It seems to be doing the trick both on the db and also on the user interface grids. Your example above is accurate. If you had scale to 0 then you would have a integer.
Jun 8 '07 #4

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

Similar topics

20
11676
by: Raoul Watson | last post by:
By any chance, anyone got a rounding routine that does a work around the VB "round" bug? I still find it amazing that a company as large as Microsoft would put out a math package that is so...
7
4091
by: Steven T. Hatton | last post by:
I'm surprised I haven't hit this situation till now, but I don't believe I've had to deal with it before. I have a function that sets the components of a point class (QPoint from Qt). It takes...
2
5106
by: Lynn N. | last post by:
I have a report showing Rate, Hours and Total Pay (which is Rate*Hours) for several workers. I want to sum the Total Pay and get a CORRECT figure. This seems like it should be such a simple task....
5
2484
by: astro | last post by:
I have a report/invoice that lists volume, price per unit, and extended price. My problem is being able to get the extended price by multiplying the x . With just 2 decimal places on both...
5
6357
by: BabyATX13 via AccessMonster.com | last post by:
I don't want to use "Bankers Rounding" For example I want to be able round 2.525 up to 2.53 Is there a simple way to do this? I have tried to read back issues on this problem and have yet to find...
5
2734
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
6
2239
by: shaqattack1992-newsgroups | last post by:
Hello Everyone, I'm using the following on a form in my database: =(-Int(-Sum((IIf(=Yes,((*)+()), (((*)+)*1.06))*100))))/100 In this case, I want to calculate a total for an order. If...
2
2994
by: apartain | last post by:
In the detail of my report I am extracting a sum from a hidden subform via the following: =IIf(.Report.HasData=True,.Report!Text19,0) Where Text19 is the sum of the items in the subform. I...
206
13093
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
4958
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
7353
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
7418
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...
1
7075
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
7508
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
5662
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
4737
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...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
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 ...
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.