Default value for a double

  • Thread starter Thread starter Jon
  • Start date Start date
J

Jon

I've read that I can use a default value to avoid a nullable type in some situations.

Is this a good idea for a double? I'm a bit worried that one normally should not use if
(valDoub==???) due to the slightly inexact way that doubles are defined.
 
Not a big deal if you are default to something without a huge amount of
precision, like 0.0. Floating points are more problematic when you have many
digits to the right of the decimal point.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
True, but I'm in the "default to 'we don't know what the value is' " (NULL)
camp. It takes even less space.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker's Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
I was just answering the question, but I would agree that NULL is a better
option that defaulting null objects. But that comes from my understanding of
how null is used in a database. ;-)

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
 
Thanks for your reply Gregory.

I wouldn't be using 0.0 as the default since this can occur naturally in my data. I might consider
using something like 1e30.

Jon


Not a big deal if you are default to something without a huge amount of
precision, like 0.0. Floating points are more problematic when you have many
digits to the right of the decimal point.

--
Gregory A. Beamer
MVP: MCP: +I, SE, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think Outside the Box! |
********************************************
 
Back
Top