java - Conversion byte decimal to byte bcd -
i need convert delphi function java function. function convert byte decimal byte bcd:
function bytetobcd(number : byte) : byte; begin result:= ((number div 10) shl 4) or (number mod 10); end;
you can this
public static int bytetobcd(byte b) { assert 0 <= b && b <= 99; // 2 digits only. return (b / 10 << 4) | b % 10; }
it not clear stuck on answer trivia.
Comments
Post a Comment