Skip to content

How to display the value of bitfiled in hex? #2120

Discussion options

You must be logged in to vote

Hey, that image is somewhat old, we used to always display both decimal and hex values for integers.
You can however still simply use a format function:

import std.io;

fn format_hex(auto value) {
    return std::format("0x{:02X}", value);
};

bitfield Test {
    unsigned value : 8 [[format("format_hex")]];
};

Test test @ 0x00;

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@cpcopy
Comment options

Answer selected by WerWolv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants