FreeBSD/sys/ddb/db_command.c
/*
 * Take the parsed expression value from the command line that was parsed
 * as a hexadecimal value and convert it as if the expression was parsed
 * as a decimal value.  Returns -1 if the expression was not a valid
 * decimal value.
 */
Take the parsed expression value from the command line that was parsed
as a hexadecimal value and convert it as if the expression was parsed
as a decimal value.  Returns -1 if the expression was not a valid
decimal value.
Take the parsed expression value from the command line that was parsed as a hexadecimal value and convert it as if the expression was parsed as a decimal value . Returns - 1 if the expression was not a valid decimal value .
db_expr_t
db_hex2dec(db_expr_t expr)
{
	uintptr_t x, y;
	db_expr_t val;
	y = 1;
	val = 0;
	x = expr;
	while (x != 0) {
		if (x % 16 > 9)
			return (-1);
		val += (x % 16) * (y);
		x >>= 4;
		y *= 10;
	}
	return (val);
}
db_expr_t db_hex2dec ( db_expr_t expr ) { uintptr_t x , y ; db_expr_t val ; y = 1 ; val = 0 ; x = expr ; while ( x != 0 ) { if ( x % 16 > 9 ) return ( -1 ) ; val += ( x % 16 ) * ( y ) ; x >>= 4 ; y *= 10 ; } return ( val ) ; }
Take the parsed expression value from the command line that was parsed
 as a hexadecimal value and convert it as if the expression was parsed
 as a decimal value.
Take the parsed expression value from the command line that was parsed as a hexadecimal value and convert it as if the expression was parsed as a decimal value .