Skip to content

Create a type instead of using short #2

@nemequ

Description

@nemequ

If nothing else it would probably be more appropriate to use int16_t instead of short. But even that should only be used internally IMHO. I think you should create your own type so it's clearer to people reading code using the API what is going on.

A simple typedef to int16_t would be an improvement, but I think a better solution would be something like typedef struct { int16_t val; } foo_float16; since it would trigger an error if people try to use arithmetic operators (+, -, *, /, etc.).

That said, some compilers have at least some support for 16-bit floats. Clang 6+ and GCC 4.5+ for starters. It would be nice if you could take advantage of that where available.

I'd also suggest you be careful about the name. float16_t is already taken by NEON, for example. Putting everything in a namespace would be an easy solution, but unfortunately calling the library "float16" is somewhat limiting there. FWIW, I probably would have been tempted to use something falcon-themed as a joke about the F-16 airplane. f16_t, maybe?

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions