如何将DINT转换为32位有符号整数? [英] How to convert a DINT to 32-bit signed integer?

查看:721
本文介绍了如何将DINT转换为32位有符号整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是一些背景.我正在处理一些特殊的I/O设备,它以32位DWORD的形式提供计数.我必须将DWORD转换为双精度整数或DINT.我们已经知道DINT和32位整数之间有什么区别?如何使用DINT?

Here is some background. I''m handling some special I/O device which provides counts as a 32-bit DWORD. I must convert the DWORD to double precision integer or DINT. What is the difference between a DINT and 32-bit integer that we already know? How do I use a DINT? Thanks!

推荐答案

您的问题不太清楚,因为双精度类型是浮点数.整数是整数.您可能还意味着您想要QWORD而不是DWORD.表示64位而不是32位的整数. c的ISO C9X类型为long longunsigned long long.

无论使用哪种类型,都应正确地投射(或舍入为浮点数).


http://www.cppreference.com/wiki/data_types [ http://msdn.microsoft.com/en-us/library/s3f49ktz% 28VS.80%29.aspx [ ^ ]

祝你好运!
Your question isn''t quite clear because a double precision type is a floating point number. An integer is a whole number. You could also mean that you want QWORD instead od a DWORD. Meaning a 64 bit integer instead of 32 bit. The ISO C9X type for c would be long long and unsigned long long.

Whatever type you use, you should cast (or round floating points) properly.


http://www.cppreference.com/wiki/data_types[^]

http://msdn.microsoft.com/en-us/library/s3f49ktz%28VS.80%29.aspx[^]

Good luck!


Jun,

您的DINT类型看起来像 WinNT.h 中定义的旧版INT的外来名称(在Windows支持的32位和64位平台上为32位带符号整数).

所以
Hi Jun,

Your DINT type looks like an exotic name for the good old INT defined in WinNT.h (a 32 bits signed integer on Windows supported 32 and 64 bits platforms).

So
#include <WinNT.h>
typedef INT DINT;

应该足够了:)
欢呼声,
AR

should be enough :)
cheers,
AR


嗨!!!

您能不能提供几行内容,例如您完全卡在哪里?我在fortran中使用了dint()和aint()很久了.我很高兴能为您提供帮助?
Hi !!!

Could you please provides few lines, like where you are stucked exactly?I used dint() & aint() in fortran a long back. I will be much pleased to help you?


这篇关于如何将DINT转换为32位有符号整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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