| 7 | #include <stdio.h> |
| 8 | |
| 9 | int main(int argc, char *argv[]) |
| 10 | { |
| 11 | fp16_t fp16val; |
| 12 | u64 u64min, u64max; |
| 13 | char *endp; |
| 14 | |
| 15 | common_setup(argv[0]); |
| 16 | |
| 17 | opt_register_noarg("-h|--help", opt_usage_and_exit, |
| 18 | "[fp16:val|value]\n" |
| 19 | "Converts to/from fp16, indicates ranges", |
| 20 | "Get usage information"); |
| 21 | opt_parse(&argc, argv, opt_log_stderr_exit); |
| 22 | if (argc != 2) |
| 23 | opt_usage_exit_fail("Expect 1 argument"); |
| 24 | |
| 25 | if (strstarts(argv[1], "fp16:")) |
| 26 | fp16val = strtoul(argv[1] + 5, &endp, 0); |
| 27 | else |
| 28 | fp16val = u64_to_fp16(strtoul(argv[1], &endp, 0), false); |
| 29 | |
| 30 | if (*endp) |
| 31 | opt_usage_exit_fail("Expect valid number"); |
| 32 | |
| 33 | u64min = u64max = fp16_to_u64(fp16val); |
| 34 | while (u64_to_fp16(u64min-1, false) == fp16val) |
| 35 | u64min--; |
| 36 | while (u64_to_fp16(u64max+1, false) == fp16val) |
| 37 | u64max++; |
| 38 | printf("fp16:0x%x\n" |
| 39 | "min %"PRIu64"\n" |
| 40 | "max %"PRIu64"\n", |
| 41 | fp16val, u64min, u64max); |
| 42 | common_shutdown(); |
| 43 | } |
nothing calls this directly
no test coverage detected