blob: 799f79a18712ab40cc3d14ccdadaad75bef8d302 [file] [log] [blame]
Gian Marco Iodice6c113ed2023-01-19 17:14:26 +00001/*
2 * Copyright (c) 2023 Arm Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#include "ckw/Error.h"
26
27#include "src/Helpers.h"
28
29namespace ckw
30{
31std::string dec_to_hex_as_string(int32_t dec)
32{
33 switch(dec)
34 {
35 case 0:
36 case 1:
37 case 2:
38 case 3:
39 case 4:
40 case 5:
41 case 6:
42 case 7:
43 case 8:
44 case 9:
45 return std::to_string(dec);
46 case 10:
47 return "A";
48 case 11:
49 return "B";
50 case 12:
51 return "C";
52 case 13:
53 return "D";
54 case 14:
55 return "E";
56 case 15:
57 return "F";
58 default:
59 COMPUTE_KERNEL_WRITER_ERROR_ON_MSG("Unsupported decimal number");
60 return "";
61 }
62}
63} // namespace ckw