|
|
View previous topic :: View next topic |
Author |
Message |
Franz Guest
|
Real problem by uchar or int8 |
Posted: Thu Apr 08, 2004 4:32 am |
|
|
Hello my problems is : Can I do a shift 24 (>> 24) by ulong byte (int32) in a uchar.
If I write:
void tipol ( ulong misura, uchar offset )
{
uchar var ;
var = 0xff&(misura >> 24) ;
............
Can i do it in a uchar?
............
Is the code correct?
Thanks in advance.
Sorry for my bad english. |
|
|
Ttelmah Guest
|
Re: Real problem by uchar or int8 |
Posted: Thu Apr 08, 2004 5:04 am |
|
|
Franz wrote: | Hello my problems is : Can I do a shift 24 (>> 24) by ulong byte (int32) in a uchar.
If I write:
void tipol ( ulong misura, uchar offset )
{
uchar var ;
var = 0xff&(misura >> 24) ;
............
Can i do it in a uchar?
............
Is the code correct?
Thanks in advance.
Sorry for my bad english. |
Yes. Since 'misura' is a 32bit value, the actual arithmetic will be done using 32bit arithmetic, and only converted at the end.
Potentially, there is a simpler instruction to get the same result:
var=make8(misura,3);
Will directly 'extract' the top byte of the 32bit value, more quickly (though the rotation should be automatically converted to a similar operation by the compilers optimisation, the 'mask' (using 0xff), will still be extra un-needed code.
Best Wishes |
|
|
Franz Guest
|
|
Posted: Wed Apr 14, 2004 9:11 am |
|
|
Thanks very much |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|