为什么没有2字节浮点数,并且已经存在实现? [英] Why is there no 2-byte float and does an implementation already exist?

查看:178
本文介绍了为什么没有2字节浮点数,并且已经存在实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我真的很想获得内存,并且想要一个较小的范围(类似于shortint).着色器语言已经为浮点类型提供了一半精度的half支持(不仅仅是将值在-1和1之间来回转换,即返回如下所示的浮点数:shortComingIn / maxRangeOfShort). 2字节浮点数已经存在吗?

Assuming I am really pressed for memory and want a smaller range (similar to short vs int). Shader languages already support half for a floating-point type with half the precision (not just convert back and forth for the value to be between -1 and 1, that is, return a float like this: shortComingIn / maxRangeOfShort). Is there an implementation that already exists for a 2-byte float?

我也想知道为什么没有2字节浮点数(历史原因).

I am also interested to know any (historical?) reasons as to why there is no 2-byte float.

推荐答案

回复:实现:显然有人为C编写了half,它(当然)可以在C ++中工作:

Re: Implementations: Someone has apparently written half for C, which would (of course) work in C++: https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/cellperformance-snippets/half.c

Re:为什么float为四个字节:可能是因为在此以下,其精度非常有限.

Re: Why is float four bytes: Probably because below that, their precision is so limited.

这篇关于为什么没有2字节浮点数,并且已经存在实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆