DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005

    is it good to set a variable to NaN?

    I've got an input file that is char count delimited.
    so var1 is the first 10 characters of a line and var2 is the second 10 characters of the same line, and so on.

    The problem is that each set of 10 chars could be just an empty string.

    right now, I have the follwoing:
    if (strEmpty(input))
       var1 = -99999
       var1 = strToVal(input)
    rather than setting it to some number, is there something like:
    if (strEmpty(input))
       var1 = LONG.NaN  // or DOUBLE.NaN, depending on the type of var1
       var1 = strToVal(input)
    If something like this is possible, then the next part is can I use it as a comparison? something like the following.

    If (var1==LONG.NaN) 
        do nothing
        do something

  2. #2
    Join Date
    Nov 2003
    Nan is a value that you never want to use in your programs. Many hardware architectures generate traps when they encounter such a value, and since NaN is not a legit value, you can't compare it with any other values (this might geremate a trap). Simply choose a special string as an agreed upon value.
    Danny Kalev

Similar Threads

  1. SQL DMO Restores in VB?
    By ObiWan in forum VB Classic
    Replies: 3
    Last Post: 05-23-2006, 10:35 AM
  2. Object variable or With block variable not set
    By Dan-Yeung in forum VB Classic
    Replies: 4
    Last Post: 02-21-2003, 10:56 PM
  3. RUNTIME ERROR saving a recordset
    By Des in forum VB Classic
    Replies: 5
    Last Post: 05-15-2002, 03:16 PM
  4. simple XML APPENDING problem
    By scopee in forum XML
    Replies: 4
    Last Post: 04-13-2001, 03:31 AM
  5. Ted, you're a prince!
    By Georgiana Trigg in forum VB Classic
    Replies: 0
    Last Post: 10-29-2000, 11:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center