Page 1 of 1

New Variable Type .bin

Posted: Thu Aug 21, 2008 2:41 am
by Rook Zimbabwe
Looking over the variable types list I see a great selection... but I was wondering if we could not add a new variable type solely for Binary numbers?

Is it even possible?

I use a string at the moment... but think it would be faster if it were an actual type!

:D

Posted: Thu Aug 21, 2008 3:08 am
by ts-soft
Binary numbers like:

Code: Select all

%1100011
?

Posted: Thu Aug 21, 2008 3:03 pm
by Kaeru Gaman
@Rook
what would you need it for?

in the end, it's only a display issue, not a storing issue.
you can display each and every number in your program in binary format.

displaying a number always means to convert it to a string.
decimal transscription is done automatically for some outputs,
thus you can just "Debug A", but under the hood it's "Debug Str(A)",
and its up to you to "Debug Bin(A)"
input handling also works via Strings,
you can convert a binary string into a value using Val() and adding a preceding "%".

Code: Select all

bin$ = "%"+Bin(170)
Debug bin$

binary.l = Val(bin$)

Debug binary
Debug Bin(binary)
PS:
here some further 'literature' about how to handle bits and what you can do with them:
Bit Twiddling Hacks: http://graphics.stanford.edu/~seander/bithacks.html

Posted: Fri Aug 22, 2008 8:08 am
by Hurga
Hm, for me it seems that he mean just 0 or 1. A variable which stores only one bit.

Posted: Fri Aug 22, 2008 11:22 am
by Hroudtwolf
I don't know such a type from other programming languages.
Also boolean types has AFAIK in many languages more than one byte.
Therefore a multiple more than one bit.

Regards

Wolf