56,687
社区成员
发帖
与我相关
我的任务
分享
declare @byte1 binary(1)
declare @byte2 binary(1)
declare @smallint smallint
set @smallint = 675
set @byte1 = @smallint & 0xFF
set @byte2 = (@smallint & 0xFF00) / 0x100
select @byte1 a, @byte2 b, @byte1+@byte2 c
CREATE DEFINER=`root`@`localhost` FUNCTION `F_TEST`( iPos tinyint
,nID int
,nLv tinyint
,nOtherID int
,iRate int) RETURNS longblob
BEGIN
return char(iPos&0xFF,
nID&0xFF,
(nID&0xFF00) / 0x100,
nLv&0xFF,
nOtherID&0xFF,
(nOtherID&0xFF00) / 0x100,
iRate&0xFF,
(iRate&0xFF00) / 0x100
);
END
CREATE FUNCTION `Sint16ToBinary2`(small_int smallint) RETURNS binary(2)
BEGIN
declare byte1 binary(1);
declare byte2 binary(1);
set @byte1 = small_int & 0xFF;
set @byte2 = (small_int & 0xFF00) / 0x100;
RETURN ( @byte1 + @byte2) ;
END