15,741,688 members
1.00/5 (1 vote)
See more:
```Hello
This function is written using Pascal software. Someone can guide what this function does?
Thanks .. ```

```procedure int2Hex(intnum:integer; var Bytes:Tsb8);
var  b,b1,b2,b3,b4,b5,b6,b7,b8:byte;
n:integer;
begin
n:= intnum;
b:=n;

b8:=b AND \$0f;
b7:=b AND \$f0;  b7:=b7 shr 4;

n:=n shr 8;
b:=n;
b6:=b AND \$0f;
b5:=b AND \$f0;  b5:=b5 shr 4;

n:=n shr 8;
b:=n;
b4:=b AND \$0f;
b3:=b AND \$f0;  b3:=b3 shr 4;

n:=n shr 8;
b:=n;
b2:=b AND \$0f;
b1:=b AND \$f0;  b1:=b1 shr 4;

end;```

What I have tried:

```What I do know is that this function takes a number and stores it in an 8-byte array?
But I do not know how he does it?
I want to implement this function in C#.
Posted
Updated 17-Jan-22 2:08am

## Solution 2

C#
```public static  byte [] getNibbles(UInt32 ui32)
{
const int Nibbles = 8;
byte [] b = new byte[Nibbles];
for ( int n=0; n<Nibbles; ++n)
{
b[n] = (byte) (ui32 & 0xF);
ui32 >>= 4;
}
return b;
}```

Member 9439045 17-Jan-22 23:26pm
Thank you for help.

## Solution 1

All it does is mask and shift values: Look up the `AND` and `shr` operators and it's pretty obvious: Pascal - Bit Operators[^]

Member 9439045 17-Jan-22 23:26pm
Thank you for help.
OriginalGriff 18-Jan-22 1:35am
You're welcome!