2

我可以用这种方式制作演员表吗?

int clockOffset;

clockOffset=((int64_t)Time_1_delayed-Time_1-Time_2_delayed+Time_2)/2;

其中所有时间变量都是uint

我想将签名结果保存在clockOffset.

4

2 回答 2

1

这是您可以在 C 中执行的操作(假设 int 和 unsigned int 比 long long 短):

#include <limits.h>

...
  unsigned int Time_1_delayed, Time_1, Time_2_delayed, Time_2;
...
  long long diff = ((long long)Time_1_delayed - Time_1 - Time_2_delayed + Time_2) / 2;
  int clockOffset;

  if (diff < INT_MIN || diff > INT_MAX)
    HandleTheError();

  clockOffset = diff;
...
于 2013-02-07T15:29:05.360 回答
1

你不需要投射。例如你可以这样做。

uint32_t a = 100;
uint32_t b = 200;
int32_t c = a - b;

你会得到c = -100.

于 2015-09-28T12:31:33.393 回答