Click here to Skip to main content
15,920,503 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL 2000 - IF / THEN bug? Pin
ToddHileHoffer17-Aug-05 10:42
ToddHileHoffer17-Aug-05 10:42 
GeneralSql server Pin
chandru_inbox17-Aug-05 0:29
chandru_inbox17-Aug-05 0:29 
GeneralRe: Sql server Pin
Yulianto.18-Aug-05 16:44
Yulianto.18-Aug-05 16:44 
GeneralRe: Sql server Pin
miah alom19-Aug-05 6:34
miah alom19-Aug-05 6:34 
GeneralNeed advice on numerical data types for numbers like ##,###.## Pin
FTrader16-Aug-05 20:41
FTrader16-Aug-05 20:41 
GeneralRe: Need advice on numerical data types for numbers like ##,###.## Pin
Colin Angus Mackay16-Aug-05 22:28
Colin Angus Mackay16-Aug-05 22:28 
GeneralRe: Need advice on numerical data types for numbers like ##,###.## Pin
FTrader16-Aug-05 23:16
FTrader16-Aug-05 23:16 
GeneralRe: Need advice on numerical data types for numbers like ##,###.## Pin
Dan Neely17-Aug-05 10:38
Dan Neely17-Aug-05 10:38 
It's not that simple. While you will have enough 'digits' to store the value in a float since floats are stored in binary format the exact values they store will not map 1:1 onto the range of base10 decimals you want. For example .1(dec) is a repeating decimal in binary and consequently cannot be stored accurately.

IF you want to avoid the performance hit of the Decimal type you could use a fixed point integer. IE store the numbers in a 32bit it, but record $2.34 as 234. If you need to multiply or divide two fixed point numbers, however you'll need to implement additional logic in the calculation because the language you're writing in won't know that 200*200 is realy 2.00*2.00 and the correct answer is 400 not 40000.

The only way to enforce this would be to write Multiply and Divide functions and always use them instead of */ to do the computations. Doing this will greatly increase the chance of bugs however since it only takes one case of using the base operator to screw your numbers up.

Despite the performance hit, you're probably better off using the Decimal type because it hides all the ugly details from you.


I'd strongly advise you at least glance over the start of the article "What every computer scientist should know about floating point arithmatic". While it is rather dense it provides clear explanation of what actually goes on behind the scenes with float and double values and explains why they won't work the way you're niavely assuming.

http://docs.sun.com/source/806-3568/ncg_goldberg.html
GeneralRe: Need advice on numerical data types for numbers like ##,###.## Pin
FTrader17-Aug-05 12:44
FTrader17-Aug-05 12:44 
GeneralRe: Need advice on numerical data types for numbers like ##,###.## Pin
Dan Neely18-Aug-05 7:57
Dan Neely18-Aug-05 7:57 
GeneralSome info about .NET decimal Pin
FTrader17-Aug-05 1:57
FTrader17-Aug-05 1:57 
QuestionDeleted entries reappearing in Access 2000 DB? Pin
mav.northwind16-Aug-05 20:28
mav.northwind16-Aug-05 20:28 
Questionhow to accessing Paradox use ADO Pin
ebinaini16-Aug-05 19:20
ebinaini16-Aug-05 19:20 
General.NET SQL Stored Procedures Pin
Carl Mercier16-Aug-05 6:36
Carl Mercier16-Aug-05 6:36 
GeneralTriggers Problem [modified] Pin
Faheem Habib15-Aug-05 23:23
Faheem Habib15-Aug-05 23:23 
GeneralRe: Triggers Problem Pin
ToddHileHoffer16-Aug-05 10:23
ToddHileHoffer16-Aug-05 10:23 
Generalneed help about analysis service connection Pin
ianpeter15-Aug-05 21:25
ianpeter15-Aug-05 21:25 
Generalanwhat's wrong with my cursor!!!!!!!!! Pin
under281115-Aug-05 21:11
under281115-Aug-05 21:11 
GeneralRe: anwhat's wrong with my cursor!!!!!!!!! Pin
Colin Angus Mackay15-Aug-05 22:11
Colin Angus Mackay15-Aug-05 22:11 
QuestionHow does .NET Data Provider for SQL Server convert varchar data to Unicode? Pin
GlennBits15-Aug-05 6:46
GlennBits15-Aug-05 6:46 
GeneralSQL Problem Pin
WDI15-Aug-05 3:39
WDI15-Aug-05 3:39 
GeneralRe: SQL Problem Pin
Colin Angus Mackay15-Aug-05 5:01
Colin Angus Mackay15-Aug-05 5:01 
GeneralSQL Error Handling... Pin
Illegal Operation15-Aug-05 0:51
Illegal Operation15-Aug-05 0:51 
GeneralRe: SQL Error Handling... Pin
Vasudevan Deepak Kumar15-Aug-05 0:54
Vasudevan Deepak Kumar15-Aug-05 0:54 
GeneralRe: SQL Error Handling... Pin
Illegal Operation15-Aug-05 20:31
Illegal Operation15-Aug-05 20:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.