C language, How can I Convert Number to String? [closed] - c

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
if I've a large number stored in 10 bytes of memory, how can I convert this number to string? like How do C %d converts number to string?
I'm not looking for some library or function, I wan't to know how to convert large byte numbers to string, that is what i need to know.

You need to use some combinatory logic to do this. A straightforward way consist in converting your 10 bytes number into BCD representation first (Binary-coded decimal), then convert your BCD number into an ASCII string, which is quite simple. Have a look at this for example: https://en.wikipedia.org/wiki/Double_dabble

Related

How we can sort numbers lexicographically without converting them to strings in C language? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have tried to sort the numbers using dictionary sort with converting them to strings.But I don't know how to sort numbers using dictionary sort without converting them to strings
Find the largest power of 10 (the number of digits of your biggest number)
Write your compare function so it does a comparison between
a * 10 ^ (max_digits - a_digits) and b * 10 ^ (max_digits - b_digits)
Apply any sort algorithm you wish with this comparison function.

C program to convert decimal to binary using AND bitwise operator [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have seen this code to convert decimal to binary using AND bitwise operator,and put the resulting binary number in an array to iterate over it later .since I'm new to C , I couldn't visualize the code
For example if we have number (13) in decimal, which equals (1101) in binary ... what exactly happens inside this for loop ?!
The loop masks off one bit of n and writes '0' or '1' to the char buffer, depending on its state, starting with the most significant bit.
In the loop it will check the each bit , wheather it is set or clear. if bit is set it will write '1' in array at the respective index or if bit is clear then it will write '0' in array at respective index.

Explain Big int in C? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I need to hold a value of range 10^20 in C. Heard that the big int in C can hold such big values. How to declare and use the big int in C.
Does anybody know of an easy way to do that? Any help would really be appreciated!
You can use type unsigned long long, the range is at least 0..18446744073709551615, but that's only 1.8E19, so slightly less than what you need. If you really want to go beyond 64 bits, you can check if your system supports 128 bit integers (as type __int128, __int128_t, int128_t or something similar) or you will need a multi-precision package such as GMP.

Which datatype is used for 10^500 in c language [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
Problem Statement
Addition is a very basic operation in mathematics. Jimmy was very weak in addition, so his father decided to teach him. Jimmy is given a number and has to perform addition on all the digits of that number till that the large number gets converted into a single digit. Your task is to prepare a program for him so that he can easily find out the final number.
Input Format
First line contains T (1<=T<=100) the number of test cases.
Each test case contains integer N (1<=N<=10^100).
Output Format
For each test case, output the one digit number by repeatedly adding the digits.
Constraints
1<=T<=100
1<=N<=10^500
I'd represent the very large input number as char, and the total of the digits (first pass) will easily fit in an int. You'll need a little more than simple arithmetic, but it shouldn't be difficult (case seems a likely way to manage the job).

Printing char values in hex inside a 1-character square in C? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
In C, is it possible to force an unsigned char to print as a hex, not with %x, but in the little square box that displays the four hex numbers, but only takes up one character, for example 轩?
No, it is not possible.
This is not related to C, but to the font your terminal uses. C outputs characters as bytes; your terminal is responsible for choosing how to display them as pixels. (You might as well ask how to make the text italic.)

Resources