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

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -