hv: lib: refine print_decimal

Align the calculate logic to make it simpler.

Tracked-On: #861
Signed-off-by: Li, Fei1 <fei1.li@intel.com>
This commit is contained in:
Li, Fei1 2018-12-04 22:00:58 +08:00 committed by wenlingz
parent 7a62154e36
commit 9c133c7bbc
1 changed files with 4 additions and 4 deletions

View File

@ -348,17 +348,17 @@ static void print_decimal(struct print_param *param, int64_t value)
v.qword = v.qword / 10UL; v.qword = v.qword / 10UL;
} }
nv.dwords.low = v.dwords.low;
/* process 32 bit (or reduced 64 bit) value */ /* process 32 bit (or reduced 64 bit) value */
do { do {
/* determine digits from right to left. The compiler should be /* determine digits from right to left. The compiler should be
* able to handle a division and multiplication by the constant * able to handle a division and multiplication by the constant
* 10. * 10.
*/ */
nv.dwords.low = v.dwords.low / 10U;
pos--; pos--;
*pos = (v.dwords.low - (10U * nv.dwords.low)) + '0'; *pos = (char)(nv.dwords.low % 10U) + '0';
v.dwords.low = nv.dwords.low; nv.dwords.low = nv.dwords.low / 10U;
} while (v.dwords.low != 0U); } while (nv.dwords.low != 0U);
/* assign parameter and apply width and precision */ /* assign parameter and apply width and precision */
param->vars.value = pos; param->vars.value = pos;