My god! How come byte has negative value!!!

dreamworld

Active Member
Licensed User
Longtime User
dim bytearray(4) as byte
bytearray(0)=202

When debugging, I moved cursor on "bytearray" and B4A shows that its value is [-54, 0, 0, 0]!
I can't believe my eyes, so I

dim I as int
I = bytearray(0)

The value of I is also -54!

How come byte data type has negative value?
Its value should be from 0 to 255.
How come byte data type has negative value?
How come byte data type has negative value?

My god! My god! My god!
 

dreamworld

Active Member
Licensed User
Longtime User
Well, I don't program with Java. What I know is that the value of byte type in BASIC language is ranged from 0 to 255, not -128 to 127.

Why don't you put this key infomation at the top of the forum or in B4A? Is it very difficult to do that?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

dreamworld

Active Member
Licensed User
Longtime User
When cursor move on a byte type variable, B4A should mention that the value of byte type is ranged from -128 to 127 below its value.
 
Upvote 0

lemonisdead

Well-Known Member
Licensed User
Longtime User
When cursor move on a byte type variable, B4A should mention that the value of byte type is ranged from -128 to 127 below its value.

Really ? I never had to be provided the information as I took the time to read the tutorials before ;)
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
There are many important topics. It is not possible to put everything in the "top of the forum".

Erel, I give you a credit for not braking!

@dreamworld,

It is time for me to publish my theory of "Beja Attitude Curve" or BAC theory of the forum.
This theory is not general and doesn't apply to all new members of the forum, but I will develop it so it can be applied to all cases of study!!!

From my experience (personal and observation)
Some new comers read ads about b4a and they mistakenly understand they are going to use the same tools they used to work with in MS VB. some even asked about ActiveX controls.. then they find out that b4a is different from vb because simply it is for Android, and therefore there must be some differences. They completely become disappointed and frustrated while trying to study it. They post inflammatory messages to the forum and try to remind Erel and other developers with the grave mistakes that they didn't follow MS way of doing things.
After some time, and with the help of others, and the determination of Erel to bring them back on track of being objective and reasonable, they slowly develop a device to re-orientate their way of thinking, and they realize that B4A yes, it is Basic Language only in the sense of how statements and functions are constructed, but because it is built on Java, then there is no work around to avoid some of Java ways in doing business.

Please see BAC cuvre
 

Attachments

  • BAC.jpg
    BAC.jpg
    18.9 KB · Views: 194
Last edited:
Upvote 0

KitCarlson

Active Member
Licensed User
Longtime User
Sorry guys, B4A is an excellent tool. Look what others have done. The information is out there. Learn to search and google. Read the guides, follow examples.

Many experienced programmers grasp statements, and data types with a true level of understanding, it enables them to program easily in many languages.
 
Upvote 0

Charlie_M

Member
Licensed User
Longtime User
some even asked about ActiveX controls..

Yea That would be me. I am not sure if some others asked about activeX controls, but to my defense I simply did not know what to call them. I have sense learned that the proper term is "views" which makes no sense to me. I agree that B4a in a great development tool and for me learninig it is a work in progress.I am used to VB and embedded development. There are a lot of things I don't understand about it. My thinking of a byte is the same as dreamworld
ie 0 to 255. Anyway I too have issues of searching for information. I know its all out there, but it would be nice to have it all in one place. just my 2 cents.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Well the byte is still 0 to 255. The difference is, when looked at from a single/decimal standpoint, it treats it as a signed int so you get a negative value.

in my case I use bytes, because the other end is a microcontroller and it doesnt care whether is signed or not. Works for me.
 
Upvote 0

Beja

Expert
Licensed User
Longtime User
Yea That would be me. I am not sure if some others asked about activeX controls, but to my defense I simply did not know what to call them. I have sense learned that the proper term is "views" which makes no sense to me.

Not only you but I also asked about ActiveX controls in the beginning of my work with b4a.. "views" make sense to me, because the object is basically a view of the class code, in fact "View" is more appropriate than ActiveX control.. VB itself is short for Visual Basic because you have a view of the class code as an object, an entity, (buttons, labels...etc). some call them software components like ICs and MCUs.. when a piece of software is self-contained and had an image (button), then this button is a view of that code.. you can call it ActiveX or ActiveY, but the truth remains that it is a view of the code as an object or a being and no more a software block.
 
Upvote 0
Top