[Gambas-user] Unending cycle "For...Next" with variable As Byte

nando nando_f at ...951...
Tue Oct 2 07:38:41 CEST 2012


When using Byte data type

The loop iteration when j=255 is 255 + 1 = 0

Thus, the end condition of j>255 can never happen
It is an endless loop.
This 'problem' is correct operation for the datatype used.
This issue arises always at the boundary of the datatype
when math takes it beyond the possible range.


---------- Original Message -----------
From: Ru Vuott <vuott at ...325...>
To: gambas-user at lists.sourceforge.net
Sent: Sun, 30 Sep 2012 15:57:56 +0100 (BST)
Subject: [Gambas-user] Unending cycle "For...Next" with variable As Byte

> Hello,
> 
> maybe I'm in the clouds.... but I don't understand why this cycle:
> 
> **********
> Public Sub Button1_Click()
> 
>   Dim j As Byte
> 
>   For j = 0 To 255
> 
>    Print j
> 
>   Next
> 
> End
> **********
> 
> runs "ad infinitum" !
> 
> Regards
> vuott
> 
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://ad.doubleclick.net/clk;258768047;13503038;j?
> http://info.appdynamics.com/FreeJavaPerformanceDownload.html
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------





More information about the User mailing list