LoginSignup
0
0

More than 5 years have passed since last update.

c++ builder > DWORDではまる > unsigned long型に対して負をとろうとしていた

Last updated at Posted at 2016-02-23
動作確認
C++ Builder XE4

DWORDではまった。

DWORD m_diff_datetime_sec;
として定義していた値に対して

m_diff_datetime_sec= -(m_diff_datetime_sec);
という処理をしていた。

DWORDはunsigned long型なのでマイナスした値はラップアラウンドして大きな値になっていた。

この値を使って補正した日付は2052年3月25日になっていた。

最近話題が出ていた stdint.h を使って uint64_t 型などとしていれば早く気づいたか、やはりそれでも見落としていたかは分からない。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0