1. A bigger piece of Pi -- comparing real numbers
To add to what Albert said,
if you do have real numbers for data types that you want to compare, use
an inequality instead of an equality...for instance,
instead of
If a = b then
use
If Abs(a-b) < 0.001 then 'or whatever is your tolerance
Warm Regards,
Crystal
*
(: have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
Albert D. Kallal wrote:
> Actally, one of the first lessons you lean in compter scicne is that "real"
> numers on a computer are ONLY an aprpociaztion.
>
> hence:
>
> Public Sub TestAdd()
>
>
> Dim MyNumber As Single
> Dim i As Integer
>
> For i = 1 To 10
> MyNumber = MyNumber + 1.01
> Debug.Print MyNumber
> Next i
> End Sub
>
>
> Here is the actual outpput of the above:
>
> 1.01
> 2.02
> 3.03
> 4.04
> 5.05
> 6.06
> 7.070001
> 8.080001
> 9.090001
> 10.1
>
> You can see that after just 7 addtions..already rounding is occuring
>
> and if we add the follwing line of code to the end of the above:
>
>
> if MyNumber = 10.1 = True then
>
> msgbox "the number is 10.1"
>
> else
> msgbox "the number is somthing else"
> endif
>
>
> The above will actuall produce:
>
> the number is something else
>
> NOTE VERY careful in the above how the actual debug.print produced 10.1, and
> DOES NOT show any rounding errors..but in fact the test condition "= 10.1"
> FAILS!!!!
>
> So, any serious software design has to take into account that real numbers
> can't be represented exactly in a computer. For most stuff this is not a
> problem, but when you write any software that will do financial
> calculations, then you must be VERY aware of rounding issues, and that
> single, or double numbers in a computer will rapidly result in rounding
> problems. "3/10th" in a computer is only an approximation of 3 over 10. That
> even applies to "1 over 10". You can't reliblairy use conditations on
> single, or double numbers in code....they will simply fail more often then
> not!!
>
>
2. GIDS 2009 .Net:: Save Big, Win Big, Learn Big: Act Before Dec 29 2008
A basic design question... How big is too big when it comes to a VB App? How many forms are too many? How many modules? How many classes? etc... When desigining an app... are there any good rules to follow with VB6. The app I'm developing currently has about 15 forms, 12 modules, 8 unique User Controls, and 3 Classes. It is a client front end for a database. Just wondering as the program continues to grow. What should I look for to break the program into seperate/smaller pieces??? Thanks for any guidance on what I'm sure is a very open-ended question.
4. templates getting bigger and bigger - Word VBA
5. Why word files with some VBA code get bigger and bigger over t
7. Translate piece of eVC code to VB.NET CF
Hi, I'm using this eVC code in VB.NET CF, but seems last parameter is wrong
defined.
* eVC code:
BOOL WriteBitmapIntoJpegFile(const CString& strOutFileName, const int
nQuality, HBITMAP hBitmap)
* VB.NET CF code:
Public Shared Function WriteBitmapIntoJpegFile(ByVal strOutFileName As
String,
ByVal nQuality As Integer, ByVal hBitmap As System.Drawing.Bitmap) As
Boolean
End Function
How can i "translate" this to VB.NET CF?
Thanks in advance.
Ray
8. 2 pieces of the same code doing different things - VB.Net