Changeset de65624 in mainline
- Timestamp:
- 2019-10-08T12:04:16Z (5 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a163d10
- Parents:
- cf9a1e2
- git-author:
- Jiri Svoboda <jiri@…> (2019-10-09 06:04:09)
- git-committer:
- Jiri Svoboda <jiri@…> (2019-10-08 12:04:16)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/capa.c
rcf9a1e2 rde65624 153 153 assert(rc == EOK); 154 154 155 /* Change units until we have no more than scapa_max_idig integer digits */ 155 156 while (capa->m / div >= maxv) { 156 157 ++capa->cunit; … … 170 171 assert(rc == EOK); 171 172 173 /* Division with rounding */ 172 174 capa->m = (capa->m + (div / 2)) / div; 173 175 capa->dp -= rdig; 176 } 177 178 /* 179 * If we rounded up from something like 999.95 to 1000.0,, we still 180 * have more than scapa_max_idig integer digits and need to change 181 * units once more. 182 */ 183 rc = ipow10_u64(capa->dp, &div); 184 assert(rc == EOK); 185 186 if (capa->m / div >= 1000) { 187 ++capa->cunit; 188 capa->dp += 3; 189 190 /* 191 * We now have one more significant digit than we want 192 * so round to one less digits 193 */ 194 capa->m = (capa->m + 5) / 10; 195 --capa->dp; 174 196 } 175 197 } … … 202 224 ret = asprintf(rstr, "%" PRIu64 " %s", ipart, sunit); 203 225 } 226 204 227 if (ret < 0) 205 228 return ENOMEM;
Note:
See TracChangeset
for help on using the changeset viewer.