是否可以将多个浮点值合并为一个浮点值,并在需要时提取值? [英] Is it possble to combine number of float values into one float value and extract the values when needed?

查看:168
本文介绍了是否可以将多个浮点值合并为一个浮点值,并在需要时提取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个iPhone应用程序的算法,其中我需要保持在内存中的数据超过了极限,所以可以表示浮点数作为一个浮点值,并检索那些值,当我需要。



例如:

 
float array [4];
array [0] = 0.12324;
array [1] = 0.56732;
array [2] = 0.86555;
array [3] = 0.34545;

float combinedvalue =?


解决方案

您不能只在 N 位存储 4N 位的信息。



如果您的号码有一些彭定,那么你可能会找到一个方案。例如,如果所有的数字都具有相似的值,您可以只存储较低精度的数字之间的差异。



但是,这种事情很难,并受到限制。


Am working on an algorithm for an iPhone app, where the data i need to keep in memory is exceeding the limit, so is it possible to represent number of float numbers as one float value and retrieve those value when i need.

For instance:

float array[4];
array[0]=0.12324;
array[1]=0.56732;
array[2]=0.86555;
array[3]=0.34545;

float combinedvalue=?

解决方案

Not in general, no. You can't store 4N bits of information in only N bits.

If there's some patten in your numbers, then you might find a scheme. For example, if all your numbers are of similar value, you could potentially store only the differences between the numbers in lower precision.

However, this kind of thing is difficult, and limited.

这篇关于是否可以将多个浮点值合并为一个浮点值,并在需要时提取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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