Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I declare MAX_DOUBLE in VB6?

According to the MSDN help for VB6

Floating-point values can be expressed as mmmEeee or mmmDeee, in which mmm is the mantissa and eee is the exponent (a power of 10). The highest positive value of a Single data type is 3.402823E+38, or 3.4 times 10 to the 38th power; the highest positive value of a Double data type is 1.79769313486232D+308, or about 1.8 times 10 to the 308th power. Using D to separate the mantissa and exponent in a numeric literal causes the value to be treated as a Double data type. Likewise, using E in the same fashion treats the value as a Single data type.

Now in the VB6 IDE I've tried to enter this

const MAX_DOUBLE as Double = 1.79769313486232D+308

however, as soon as I move away from that line the IDE throws an Error 6 (Overflow)

An overflow results when you try to make an assignment that exceeds the limitations of the target of the assignment. ...

So how do I get MAX_DOUBLE (and MIN_DOUBLE for that matter) defined?

like image 997
bugmagnet Avatar asked Feb 28 '23 16:02

bugmagnet


1 Answers

Edit: Solved it!

Const test As Double = 1.79769313486231E+308 + 5.88768018655736E+293

Double checked it down to the binary level, that should be as high as you can go. You can keep adding values like 1 etc but it yields a number equal to, not greater than. Output is this: 01111111|11101111|11111111|11111111|11111111|11111111|11111111|11111111 Which is indeed DoubleMax

Old: You could just use Positive infinity.

like image 142
Oorang Avatar answered Mar 11 '23 20:03

Oorang