Skip to content

How to name methods for integer type conversions? #46

@kornelski

Description

@kornelski

When converting from 8 to 16 bits (or 16 to 32, etc.), there are two ways:

  • Change 0x12 to 0x1212. This is semantically the same color, but with more precision.

  • Change 0x12 to 0x0012. This keeps the same numeric value, but makes the numeric range bigger. This is useful for arithmetic, e.g. when you calculate sums and averages of pixel values.

What do you call these operations? Are there existing libraries/standards that have established names for these functions?

And similarly conversion the other way: 0x1234 can become either 0x12 or 0x34, depending on use-cases and interpretation of the values.

How to name these things? Can the different conversions to larger and smaller types have names that are clearly opposites of each other?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions