OVERFLOW ERROR with Double in VB

OVERFLOW ERROR with Double in VB

Post by John E Salte » Fri, 06 Nov 1992 06:27:18



What am doing wrong to cause the OVERFLOW ERROR.
If it is a VB problem, is there a work around?
I am trying to do logical ORing of bits in double numbers.

    Dim tbits As Double
    Dim sbits As Double
    Dim wbits As Double
    sbits = 0
    tbits = 2 ^ 36              'This statement is OK
    form1.Print sbits           'This is OK
    form1.Print tbits           'This is OK
    wbits = sbits Or tbits      'Produces OVERFLOW ERROR
    form1.Print sbits Or tbits  'Produces OVERFlOW ERROR

John Salter

 
 
 

OVERFLOW ERROR with Double in VB

Post by Brian Wheel » Fri, 06 Nov 1992 23:11:35



>What am doing wrong to cause the OVERFLOW ERROR.
>If it is a VB problem, is there a work around?
>I am trying to do logical ORing of bits in double numbers.
>    Dim tbits As Double
>    Dim sbits As Double
>    Dim wbits As Double
>    sbits = 0
>    tbits = 2 ^ 36              'This statement is OK
>    form1.Print sbits           'This is OK
>    form1.Print tbits           'This is OK
>    wbits = sbits Or tbits      'Produces OVERFLOW ERROR
>    form1.Print sbits Or tbits  'Produces OVERFlOW ERROR
>John Salter


Logical operators work only on integers.  variables that are stored as Double
have a format somthing like this:
        SEEEEEEEEEEMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
where:
        S is the sign (1 bit)
        E is the exponent (10 bits)
        M is the mantissa (53 bits)

(I may be a little off on the bit counts)

so it doesn't make any sense to OR something with this because it isn't in a
true binary number format.
I suggest using LONG or INTEGER.  LONG is 32 bits (I think) and INTEGER is 16
bits, and both are signed.

        Hope this helps
--
******************************************************************************
* Brian 'Nautical' Wheeler - These are my opinions, do you hear me?  MINE!
* "Wombats are our friends" - Me
******************************************************************************

 
 
 

OVERFLOW ERROR with Double in VB

Post by EE U7809 » Sat, 07 Nov 1992 10:17:00



Quote:> What am doing wrong to cause the OVERFLOW ERROR.
> If it is a VB problem, is there a work around?
> I am trying to do logical ORing of bits in double numbers.

>     Dim tbits As Double
>     Dim sbits As Double
>     Dim wbits As Double
>     sbits = 0
>     tbits = 2 ^ 36              'This statement is OK
>     form1.Print sbits           'This is OK
>     form1.Print tbits           'This is OK
>     wbits = sbits Or tbits      'Produces OVERFLOW ERROR
>     form1.Print sbits Or tbits  'Produces OVERFlOW ERROR

I think this is *not* a bug in Visual Basic. Because the Double data format
is Sign+Exp+Mantessa. If we OR two Double number, the result is useless and
meaningless. So if you really want to perform 2 8-byte number OR/AND/Other
boolean operation. Use Currency instead.
--
===============================================================================
 Yuh-Fuu Wu                                      National Tsing-Hua University

                                                 Hsin-Chu City, 300
 Like MS Visual Basic most!                      Taiwan, ROC
===============================================================================
 
 
 

1. int/float/double overflow / underflow

 Hello

        Does anyone know how to detect for int/float/double overflow and
underflow in c++ (without resort to using a larger representation)?

--
Best regards
FROM NCHFREAK

Sent via Deja.com http://www.deja.com/
Before you buy.

2. determining identity of AppleEvents client

3. Anyone using a Conner 3050 52 meg HD out there?

4. Debugging VB add-ins?

5. Bounding Box vs. Bounding Spheres

6. divide overflow error

7. visual language parsers?

8. Stack overflow and OWL error -6 (out of mem)

9. VC++: Heap overflow error?

10. Help! Stack Overflow Error

11. Set environment variables of vc6 error : overflow environment space ??

12. Stack overflow error?