我不熟悉C++和当前面临的有关使用double类型的size_t计算的问题。 我提供了一部分源代码如下。变量“storage”定义为double,“pos”定义为size_t类型。他们怎么能一起计算?我查看“pos”的值,它显示的值如0,1,2等等,而且,在double * result = storage + pos的情况下,显示108 + 2得出结果x 117.C++ size_t和double类型的计算
此外,有时108 + 0出来的结果X为零。什么情况导致的结果?
如何计算之前知道的size_t的确切价值?
任何意见&建议表示赞赏。
double* getPosValue(size_t pos, IdentifierType *idRule, unsigned int *errorNumber, bool *found)
{
double * storage = *from other function with value 108*
double* result = storage + pos;
uint16_t* stat = status + pos; }
是的,这些不是创建double * storage = 108的方式;存储的价值是由另一个功能给出的。抱歉的错字(从函数返回的值是108.000000)。 – 2014-11-24 05:58:38
感谢您的回复。 int i = sizeof(pos)返回4,但它不是我喜欢的数据值。我想知道size_t中的数值,如108 + 12 = 120等数学计算。它返回108 + 4 = 117或108 + 2 = 0.你能帮我...谢谢。 – 2014-11-24 06:36:30
感谢您的回复。还有一个问题,我如何将size_t转换为像double * pos这样的指针?谢谢你的建议。 – 2014-11-24 10:15:25