Mirage Source
Data Types - Visual Basic 6 and C++ - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49)
+---- Thread: Data Types - Visual Basic 6 and C++ (/showthread.php?tid=408)



Data Types - Visual Basic 6 and C++ - Obsidian - 07-11-2006

These are the listed data types that can be used, their ranges (minimum and maximum values), and how many bytes they use:

Type: Byte
Bytes Used: 1
Range: 0 to 255

Type: Integer
Bytes Used: 2
Range: – 32,768 to 32,767

Type: Long
Bytes Used: 4
Range: – 2,147,483,648 to 2,147,483,647

Type: Single
Bytes Used: 4
Range: – 3.402823E38 to – 1.401298E – 45 (negative values)
1.401298E – 45 to 3.402823E38 (positive values)

Type: Double
Bytes Used: 8
Range: – 1.79769313486231E308 to – 4.94065645841247E – 324 (negative values)
4.94065645841247E – 324 to 1.79769313486231E308 (positive values)

Type: Currency
Bytes Used: 8
Range: 922,337,203,685,477.5808 to 922,337,203,685,477.5807

Type: String
Bytes Used: String Length
Range: Zero to approximately two billion characters

Type: Variant
Bytes Used: 16 bytes, plus 1 byte for each character if a string value.
Range: Date values: January 1, 100 to December 31, 9999
Numeric values: same range as Double
String values: same range as String Can also contain Error or Null values

Type: Boolean
Bytes Used: 2
Range: True or False

Type: Date
Bytes Used: 8
Range: January 1, 100 to December 31, 9999

Type: Object
Bytes Used: 4
Range: Any "Object" Reference




I thought these would be useful to anyone writting code, or trying to better understand how vb handles different memory values with the different data types available.

Enjoy Smile


- Clu - 08-11-2006

cool, thx obs, I hadnt heard of Currency, or Date ones lol


- Misunderstood - 08-11-2006

Dave Wrote:Now here's a question for you.

Why use a boolean variable, when they take two bytes, and you only need one bit to effectively store a true/false condition?

Use a Byte instead. If you're good, you can use all 8 bits in the byte to store 8 seperate booleans. Woot

Convenience, sometimes you don't need to worry about the memory.


- Obsidian - 08-11-2006

can someone sticky and/or move this to the Knowledge base forum for future reference?


- William - 11-01-2007

[Image: datatypes.jpg]


- grimsk8ter11 - 11-01-2007

Those aspiring to port to C++ or just learn it:

char
Character or small integer.
1 byte
signed: -128 to 127
unsigned: 0 to 255

short int (short)

Short Integer.
2bytes
signed: -32768 to 32767
unsigned: 0 to 65535

int
Integer.
4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295

long int (long)
Long integer.
4bytes
signed: -2147483648 to 2147483647
unsigned: 0 to 4294967295

bool
Boolean value.
It can take one of two values: true or false.
1byte
true or false

float
Floating point number.
4bytes
3.4e +/- 38 (7 digits)

double
Double precision floating point number.
8bytes
1.7e +/- 308 (15 digits)

long double
Long double precision floating point number.
8bytes
1.7e +/- 308 (15 digits)

wchar_t
Wide character.
2bytes
1 wide character

void
No associated datatype (accepts any type)