File: BCDtoDecimal.cpp

package info (click to toggle)
librepfunc 1.10.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 424 kB
  • sloc: cpp: 1,601; makefile: 270
file content (12 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
/*******************************************************************************
 * librepfunc - a collection of common functions, classes and tools.
 * See the README file for copyright information and how to reach the author.
 ******************************************************************************/
#include <repfunc.h>

std::intmax_t BCDtoDecimal(std::intmax_t bcd) {
  std::intmax_t result = 0;
  for(std::intmax_t scale=1; bcd; scale*=10,bcd>>=4)
     result += scale * (bcd & 15);
  return result;
}