From: Boris P. on
I am reading from a binary file and I fill an array of singles with the
values.
In my file I have several QNANs. Is there any equivalent of QNANs in VB6?
I have to store in the array that that these values are QNAN, I cannot
simply skip them.
Instead of an array of singles, I could make an array of udts with

Private Type Single2
.Value As Single and
.IsQNAN As Boolean
End Type

But that would seem really overkill to me.

From: Jim Mack on
Boris P. wrote:
> I am reading from a binary file and I fill an array of singles with
> the values.
> In my file I have several QNANs. Is there any equivalent of QNANs
> in VB6? I have to store in the array that that these values are
> QNAN, I cannot simply skip them.
> Instead of an array of singles, I could make an array of udts with
>
> Private Type Single2
> .Value As Single and
> .IsQNAN As Boolean
> End Type
>
> But that would seem really overkill to me.

As long as you're simply storing them, QNaNs should not cause any
problems in VB. The "Q" in QNaN stands for Quiet, meaning that their
mere presence does not cause an exception, and they may serve as
inputs to expressions that permit them (though the results of such
expressions may be SNaNs).

--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"

From: dpb on
Boris P. wrote:
>
> I am reading from a binary file and I fill an array of singles with the
> values.
> In my file I have several QNANs. Is there any equivalent of QNANs in VB6?
> I have to store in the array that that these values are QNAN, I cannot
> simply skip them.
> Instead of an array of singles, I could make an array of udts with
>
> Private Type Single2
> .Value As Single and
> .IsQNAN As Boolean
> End Type
>
> But that would seem really overkill to me.

No concept of NaN, Q or otherwise in VB6. Altho I've not tried it; I'm
not very confident the runtime won't bomb on the GET if you try to read
the file as is.

Something like your above is all that comes to me at the moment in
native VB w/o a mixed-language module. (Perhaps/probably one of the
gurus will come along and show the way... :) )

--
From: ralph on
On Fri, 09 Jul 2010 14:24:25 +0200, "Boris P."
<bpnotvalid(a)nospamhotmail.com> wrote:

>
>I am reading from a binary file and I fill an array of singles with the
>values.
>In my file I have several QNANs. Is there any equivalent of QNANs in VB6?
>I have to store in the array that that these values are QNAN, I cannot
>simply skip them.
>Instead of an array of singles, I could make an array of udts with
>
>Private Type Single2
> .Value As Single and
> .IsQNAN As Boolean
>End Type
>
>But that would seem really overkill to me.

Yep.
But little choice.

Traditionally this is has been resolved by defining a specific value
or range of values as the exception within a set of numbers.
eg.
Can your Singles ever be zero, or greater than 1, or greater than
some high integer value, like 3200? (Doubles would give you greater
scale.)

Or you could use a UDT or Variant. With an array of Variants for
example, you might define a String as a NAN.

You might use two arrays or a 2 dimensional array. One for the values,
one to indicate if Valid or not. This can be slightly faster for some
computations.

-ralph
From: Dee Earley on
On 09/07/2010 13:24, Boris P. wrote:
> I am reading from a binary file and I fill an array of singles with the
> values.
> In my file I have several QNANs. Is there any equivalent of QNANs in VB6?
> I have to store in the array that that these values are QNAN, I cannot
> simply skip them.

I have seen somewhere (I can't give references) code that set the
internal float values of "inf", "nan" and a few others.
Essentially, it went behind VB's back and wrote to the memory directly.

Also, how are they stored in the file?
presumable as binary, they have some value that represents each state so
you may be able to just read that in direct and "decode" back to a float
when you need it (if it's valid).
This could then be stored as a byte array or a long, etc.

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)