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