Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

Convert dec to hex using nios ii

Altera_Forum
Honored Contributor II
1,537 Views

I was curious if there were a list of functions, in Nios ii using C, that convert decimal values to hex, binary etc... I am use to programming in Matlab so I am use to the quick and easy hex2dec converter. Thanks.

0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
303 Views

Nios or any other cpu always works with binary values. Other numeric bases makes sense only for formatted input/output. 

In this case the common stdio printf/scanf functions can do what you are asking for: 

printf("%d", v) : v in decimal format 

printf("%x", v) : v in hex format 

printf("%o", v) : v in octal format
Altera_Forum
Honored Contributor II
303 Views

I tend to avoid all the scanf() family of functions, they are very difficult to use safely. 

One of the strtoul() family is generally better for converting ascii input strings.
Altera_Forum
Honored Contributor II
303 Views

do take note if the convertion that to hex 16 bit or 32 bit based hex value.

Reply