- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
do take note if the convertion that to hex 16 bit or 32 bit based hex value.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page