Standard Data Type Limits
Re: Standard Data Type Limits
Without considering the implementation under the hood (one byte), a FreeBASIC Boolean contains only two values: False or True, as viewed by a user.
For compatibility with other languages, FreeBASIC allows conversion without warning of only 3 numeric values -1 / 0 / + 1 to True / False / True respectively (so it is only a conversion).
A pure Boolean therefore has no limit values.
(a pure Boolean has only two states: False or True)
For compatibility with other languages, FreeBASIC allows conversion without warning of only 3 numeric values -1 / 0 / + 1 to True / False / True respectively (so it is only a conversion).
A pure Boolean therefore has no limit values.
(a pure Boolean has only two states: False or True)
Re: Standard Data Type Limits
What do you mean?fxm wrote:For compatibility with other languages, FreeBASIC allows conversion without warning of only 3 numeric values -1 / 0 / + 1 to True / False / True respectively (so it is only a conversion).
A pure Boolean therefore has no limit values.
Re: Standard Data Type Limits
A pure boolean is not a number (I think). You cannot make a range of sequential boolean values and no minimum and maximum limit.
Also, you cannot add or subtract booleans, see:
Also, you cannot add or subtract booleans, see:
Code: Select all
dim as boolean a = true, b = true
print a + b 'type mismatch
Re: Standard Data Type Limits
Example from GfaBasic, with False=0 and True=-1:
So if some$ had the understroke, Result$ would be 2 chars long, otherwise 3. Since I wrote this stuff 30 years ago, my programming style has changed, but the example demonstrates that treating booleans as numbers can be useful in some cases.
Code: Select all
MyBool!=MID$(some$,3,1)="_"
Result$=LEFT$(some$,3+MyBool!)
Re: Standard Data Type Limits
This is more academic and about taxonomy and complete documentation than anything and whether BOOLEAN is a "Data Type". You can't add letters either, but they are listed as a data type in the doc (though I'm certain someone will say that, technically, you can). It seems to me the only one missing is BOOLEAN. It is a data type (IMHO), requires a defined amount of storage, can be read, stored, moved and even used in a computation. Is it an 8 bit format with only two "values" or should it be defined some other way?
Re: Standard Data Type Limits
See the BOOLEAN documentation page, updated in the wiki:
- Under the hood, a FreeBASIC boolean is implemented as a 1-bit wide data (but in a byte) that allows to code the boolean value (0=>False, 1=>True).
- Seen from the user, a FreeBASIC boolean has only 2 values: False or True.
- Otherwise, when assigning a boolean with an integer value (by implicit conversion and not with the False or True value), '0' induces the False state and '1' or '-1' induces the True state (any other value also induces the True state, but with a warning message).
- Otherwise when assigning a numeric type with a boolean (by implicit conversion), False induces the '0' value and True induces the '-1' value.
See also:
- TblVarTypes → fxm [added Boolean type]
- Under the hood, a FreeBASIC boolean is implemented as a 1-bit wide data (but in a byte) that allows to code the boolean value (0=>False, 1=>True).
- Seen from the user, a FreeBASIC boolean has only 2 values: False or True.
- Otherwise, when assigning a boolean with an integer value (by implicit conversion and not with the False or True value), '0' induces the False state and '1' or '-1' induces the True state (any other value also induces the True state, but with a warning message).
- Otherwise when assigning a numeric type with a boolean (by implicit conversion), False induces the '0' value and True induces the '-1' value.
See also:
- TblVarTypes → fxm [added Boolean type]
Re: Standard Data Type Limits
I think he means that boolean is either zero or non-zero (indicated by 1 or -1), whereas other numeric types such as a byte has limits (positive 127 signed and 255 unsigned.jj2007 wrote:What do you mean?fxm wrote:For compatibility with other languages, FreeBASIC allows conversion without warning of only 3 numeric values -1 / 0 / + 1 to True / False / True respectively (so it is only a conversion).
A pure Boolean therefore has no limit values.
-
- Posts: 606
- Joined: Nov 28, 2012 1:27
- Location: CA, USA moving to WA, USA
- Contact:
Re: Standard Data Type Limits
Interesting that it WAS in that table, and now removed. WHY? WHEN?
With no discussion, again? Who is the dictator that makes these decisions with no discussion in the community?
There IS a range of values: true and false.
Not worth arguing this.
Someone thinks their logic is better than clarity and convenience for the users.
david
With no discussion, again? Who is the dictator that makes these decisions with no discussion in the community?
There IS a range of values: true and false.
Not worth arguing this.
Someone thinks their logic is better than clarity and convenience for the users.
david
Re: Standard Data Type Limits
About TblVarTypes I guess:
What are you talking?
Nothing has been removed since I added the Boolean type.
I just recently moved up the Boolean type table before "Arrays" which seems logical (because we can also define Boolean arrays).
My mother always told me:
"You have to turn your tongue seven times in your mouth before speaking".
What are you talking?
Nothing has been removed since I added the Boolean type.
I just recently moved up the Boolean type table before "Arrays" which seems logical (because we can also define Boolean arrays).
My mother always told me:
"You have to turn your tongue seven times in your mouth before speaking".
-
- Posts: 606
- Joined: Nov 28, 2012 1:27
- Location: CA, USA moving to WA, USA
- Contact:
Re: Standard Data Type Limits
Interesting quote.
I don't know what I was looking at, but I am wrong; you are correct.
I apologize; I am in error.
david
I don't know what I was looking at, but I am wrong; you are correct.
I apologize; I am in error.
david