Blame view
lib/strmhz.c
412 Bytes
0768b7a87
|
1 2 3 4 |
/* * (C) Copyright 2002-2006 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601
|
5 |
* SPDX-License-Identifier: GPL-2.0+ |
0768b7a87
|
6 7 |
*/ #include <common.h> |
55f7934d2
|
8 |
char *strmhz (char *buf, unsigned long hz) |
0768b7a87
|
9 10 11 |
{ long l, n; long m; |
4515992fc
|
12 |
n = DIV_ROUND_CLOSEST(hz, 1000) / 1000L; |
0768b7a87
|
13 |
l = sprintf (buf, "%ld", n); |
d50c7d4be
|
14 15 |
hz -= n * 1000000L; |
4515992fc
|
16 |
m = DIV_ROUND_CLOSEST(hz, 1000L); |
0768b7a87
|
17 18 19 20 |
if (m != 0) sprintf (buf + l, ".%03ld", m); return (buf); } |