小编Sen*_*yai的帖子

奇怪的uint32_t浮点数组转换

我有以下代码片段:

#include <cstdio>
#include <cstdint>

static const size_t ARR_SIZE = 129;

int main()
{
  uint32_t value = 2570980487;

  uint32_t arr[ARR_SIZE];
  for (int x = 0; x < ARR_SIZE; ++x)
    arr[x] = value;

  float arr_dst[ARR_SIZE];
  for (int x = 0; x < ARR_SIZE; ++x)
  {
    arr_dst[x] = static_cast<float>(arr[x]);
  }

  printf("%s\n", arr_dst[ARR_SIZE - 1] == arr_dst[ARR_SIZE - 2] ? "OK" : "WTF??!!");

  printf("magic = %0.10f\n", arr_dst[ARR_SIZE - 2]);
  printf("magic = %0.10f\n", arr_dst[ARR_SIZE - 1]);
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果我在MS Visual Studio 2015下编译它,我可以看到输出是:

WTF??!! …
Run Code Online (Sandbox Code Playgroud)

c++ sse vectorization visual-studio

9
推荐指数
3
解决办法
554
查看次数

与Django ORM自助​​加入

我有一个模型:

class Trades(models.Model):  
    userid     = models.PositiveIntegerField(null=True, db_index=True)
    positionid = models.PositiveIntegerField(db_index=True)
    tradeid    = models.PositiveIntegerField(db_index=True)
    orderid    = models.PositiveIntegerField(db_index=True)  
    ...
Run Code Online (Sandbox Code Playgroud)

我想执行下一个查询:

select *
from trades t1
inner join trades t2
ON t2.tradeid = t1.positionid and t1.tradeid = t2.positionid
Run Code Online (Sandbox Code Playgroud)

使用Django ORM可以做到没有黑客的攻击吗?谢谢!

django

5
推荐指数
1
解决办法
4156
查看次数

标签 统计

c++ ×1

django ×1

sse ×1

vectorization ×1

visual-studio ×1