Difference between Byte() and .byte0

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
SHughes_Fusion
Posts: 219
Joined: Wed Sep 11, 2013 1:27 pm
Location: Chesterfield

Difference between Byte() and .byte0

Post by SHughes_Fusion » Fri May 19, 2017 3:36 pm

Is there any difference either the result or code generated between different ways of casting variables?

For example, if I have a variable 'Number' defined as a LongInt, is Byte(Number) the same as Number.byte0?

Simple question, but I can't find anything in the manual and have realised I use both variants in my code.

Jerry Messina
Swordfish Developer
Posts: 1469
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: Difference between Byte() and .byte0

Post by Jerry Messina » Fri May 19, 2017 7:46 pm

There's no difference that I'm aware of, at least not with that simple example.
Both versions just take the LSB and copy it to the byte variable. Same code.

One difference that I know of is you can use the 'cast' form with constants, like b = byte(-1)

Post Reply