我 我心飞翔 Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #1 假如有一数据123(integer或String),我怎么取得这个数的高6位和低4位?
O OopsWare Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #2 function GetHi6ofInt( value: integer ): integer; begin Result := (value and $000000FC) shr 4; end; function GetLo4ofInt( value: integer ): integer; begin Result := (value and $0000000F); end;
function GetHi6ofInt( value: integer ): integer; begin Result := (value and $000000FC) shr 4; end; function GetLo4ofInt( value: integer ): integer; begin Result := (value and $0000000F); end;
T takashiki Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #3 同意楼上,补充一下: 字符串后4位: function GetLo4ofStr( s:string): integer; begin Result := ord(s[Length(s)]); end; 字符串前6位: function GetHi6ofStr( s:string): integer; begin Result := (ord(s[Length(1)]) shl 2) + (ord(s[length(2)]) shr 2); end;
同意楼上,补充一下: 字符串后4位: function GetLo4ofStr( s:string): integer; begin Result := ord(s[Length(s)]); end; 字符串前6位: function GetHi6ofStr( s:string): integer; begin Result := (ord(s[Length(1)]) shl 2) + (ord(s[length(2)]) shr 2); end;
我 我心飞翔 Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #4 谢谢各位。还有一个问题: 一个Byte就是D7=0,D6=1,D5至D0是由一个数的高6位组成,请问怎样把它组成一个Byte?
L lichdr Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #5 01000000 or GetHi6ofStr( )
F firstrose Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #6 var a,b:byte; begin a=$40 OR (b AND $3F); end;
F firstrose Unregistered / Unconfirmed GUEST, unregistred user! 2003-08-25 #8 呀,抱歉! 应该是 var a,b:byte; begin a=$40 OR (b shr 2); end;