Page 1 of 1
Memory
Posted: Sun Nov 24, 2002 8:40 pm
by Guest
Yet another question for you experts... If I need an array of switches , simple values... is it more efficient memory-wise to make them string *1 or integer? In my programming experience, numbers are always far more efficient than strings, however, a QB integer is two-bytes while a string * 1 is one byte??? Is that right? If so, wouldn't it be more efficient to store these values as string * 1? Thanks for any help!
Re: Memory
Posted: Mon Nov 25, 2002 2:17 am
by frankiebaby
Yes, that is correct, variable length strings require 4 bytes for the descriptor, and one byte afterwords, fixed only use 1 byte each character.
You can find all the data type memory requirements in Qb's Online Help under CONTENTS --> DATA TYPES --> Variable-Type Memory Requirements.
Re: Memory
Posted: Thu Nov 28, 2002 7:50 am
by Guest
making a byte out ot a string is not a good Idea.
as you can see string*1 would take more than 1 byte because of the string descriptor which is 7 bytes long.
try this instead:
to put values:
A%=(Byte2%*256) or Byte1%
to get values:
Byte1%=A% and 255
Byte2%=A%\256
That way you could represent 2 bytes in one integer.
Re: Memory
Posted: Tue Dec 03, 2002 8:15 pm
by Guest
Thank you relsoft. Using strings to store switches instead of integers didn't sound right. Goes against anything I've ever worked with before. I'll experiment with your byte code... Thank you again.