在Sql Server中存储UInt32的最佳方式 [英] Best way to store UInt32 in Sql Server

查看:883
本文介绍了在Sql Server中存储UInt32的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个使用第三方组件的应用程序,该组件返回一个类型为UInt32的值。

I'm working on an application that uses a third-party component, and this component returns a value that is of type UInt32.

我需要存储这个UInt32在Sql Server表中。我想到只使用一个简单的int列,并插入如下值:

I need to store this UInt32 in a Sql Server table. I was thinking about just use a simple int column and insert the value like this:

int value = (int)(cs - int.MaxValue);

但我不知道这是否是这种任务的最佳方式。

But I'm not sure if this is the best way for such task.

推荐答案

你应该得到+ int.MinValue。对于32位有符号整数,最大值为2147483647,最小值为-2147483648。零从正侧偷取一个值。

You should probably take + int.MinValue. As max is 2147483647 and min is -2147483648 for 32 bit signed integer. The zero steals one value from the positive side.

这篇关于在Sql Server中存储UInt32的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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