michael@0: /* michael@0: * dec2hex.c michael@0: * michael@0: * Convert decimal integers into hexadecimal michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: #include "mpi.h" michael@0: michael@0: int main(int argc, char *argv[]) michael@0: { michael@0: mp_int a; michael@0: char *buf; michael@0: int len; michael@0: michael@0: if(argc < 2) { michael@0: fprintf(stderr, "Usage: %s \n", argv[0]); michael@0: return 1; michael@0: } michael@0: michael@0: mp_init(&a); mp_read_radix(&a, argv[1], 10); michael@0: len = mp_radix_size(&a, 16); michael@0: buf = malloc(len); michael@0: mp_toradix(&a, buf, 16); michael@0: michael@0: printf("%s\n", buf); michael@0: michael@0: free(buf); michael@0: mp_clear(&a); michael@0: michael@0: return 0; michael@0: }