Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Beta Versions
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Beta Versions This forum is the place to discuss issues regarding Basic4ppc beta versions.

What variable type to declare

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-26-2010, 02:56 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default What variable type to declare

Some questions :

What variable type, from the perfomance point of view, should be used for:

1) For-Next loops ? For i=0 to 100
i as Number or undefined, Integer is not supported ?

2) array variable indexes Dim x(i,j) ?
i and j as Number, Integer or undefined ?

3) drawing, pixels Drawer.DrawRectangle2(pen.Value, x1, y1, w, h)
x1,y1, w, h Integer or Number ?

4) Why not having used the standard variable type names for the declarations ?
Double instead of Number ?
Int32 instead of Integer ?

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
  #2 (permalink)  
Old 02-26-2010, 03:11 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

1,2,3) Basic4ppc internally does all the calculations with doubles. So an integer will be first cast to double and eventually back to integer. So double will be faster.
Note that this may change in the future.
I believe that in most cases the difference between integer to double will be insignificant.

4) Using Number is equivalent to using Double and the same is correct for Integer and Int32.
I think that from a developer point of view who is not familiar with all the .Net data types (and especially since double is the best choice in almost all cases in Basic4ppc) declaring a variable as Number is more clear than declaring it as a Double.
__________________
Basic4android documentation
Reply With Quote
  #3 (permalink)  
Old 02-26-2010, 03:13 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 3,827
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

Thank's for the explanations Erel.

Best regards.
__________________
Klaus
Switzerland
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Local variable cannot hid global variable jschuchert Questions (Windows Mobile) 6 10-30-2009 03:58 PM
Meldung: Local variable cannot hide a global variable JOTHA German Forum 2 07-18-2009 12:34 PM
DIM TYPE - redimming is it possible mattsaintdev Questions (Windows Mobile) 2 12-15-2008 10:45 AM
Leading zero(s) for numeric or string type variable not saved in database. mozaharul Questions (Windows Mobile) 1 10-26-2008 05:18 PM
How to declare array of structures of bytes HARRY Questions (Windows Mobile) 3 02-13-2008 05:28 PM


All times are GMT. The time now is 01:50 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0