Anonymous
Not applicable
Nov 04, 2015
12:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 04, 2015
12:48 AM
Hello guys,
I need to convert some hugh values (~120000) into binary code. Unfortunately this only works if my value is 1023 or less.
Does anyone have an idea? Is something wrong with the conversion or just with the sprintf? I tried to change the argument %... of sprintf but no success.
long num, decimal_num, remaind, base =1, binary =0;
num= 1023;
decimal_num = num;
while (num>0)
{
remaind = num %2;
binary = binary + remaind * base;
num = num/2;
base=base*10;
}
sprintf(TransmitBuffer, "real_comb_binary: %ld \n", binary);
UART_1_PutString(TransmitBuffer);
Thanks in advance,
Alex
Labels
- Labels:
-
PSoC 5LP
7 Replies