半precision转换 [英] Half precision conversion

查看:169
本文介绍了半precision转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎么来了 0 11110 1111111111 等于半precision格式 1.1111111111 * 2 ^ 15 ?两者应为65504。

How comes that 0 11110 1111111111 is equal to the half precision format 1.1111111111 * 2^15? Both should be 65504.

这里的符号位为0的指数是11101和小数部分1111111111.但是,这并不像 1.1111111111 * 2 ^ 15 可言。

The sign bit here is a 0. The exponent would be 11101 and the fractional part 1111111111. But that doesn't look like 1.1111111111 * 2^15 at all.

有人可以解释这样对我?

Can someone explain that to me?

推荐答案

下面是你半precision数的布局:

Here is the layout of your half-precision number:

数字版面

该指数的值是11110 2 ,这是30 10 。半precision数字有指数偏置的15 <子> 10 ,所以我们需要从30 10 10 >获得15 10

The exponent's value is 111102, which is 3010. Half-precision numbers have exponent bias of 1510, so we need to subtract 1510 from 3010 to get the actual exponent of 1510.

有一个隐含的1 2 pre-挂起的分数,因此实际分数在它的前面有一个额外的1。该二进制小数点紧靠隐式1后,使得这个样子的号码:

There is an implicit 12 pre-pended to the fraction, so the actual fraction has one extra 1 in front of it. The binary fraction point is located immediately after that implicit 1, making the number look like this:

1.1111111111

为了申请15 10 的二进制指数,我们需要十五个位置移动分数点的权利。这将产生数1111111111100000 2 ,这是转换后相当于65504 10

In order to apply the binary exponent of 1510, we need to move the fraction point fifteen positions to the right. This produces the number 11111111111000002, which is equal to 6550410 after the conversion.

这篇关于半precision转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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