Default value for a double

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.
 
G

Gregory A. Beamer

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! |
********************************************
 
W

William Vaughn \(MVP\)

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)
____________________________________________________________________________________________
 
G

Gregory Beamer

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! |
********************************************
 
J

Jon

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! |
********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top