私はちょうど(3日前のように)コード化する方法を学び始めています。そして、私はいくつかの問題があります。まず、 "int"、 "long int"、 "unsigned int" 。C++ long int intと同じですか?
#include <iostream>
#include <limits.h>
using namespace std;
int main() {
int value = 2147483647;
cout << value << endl;
cout << "Max int value: "<< INT_MAX << endl;
cout << "Min int value: "<< INT_MIN << endl;
long lvalue = 568534534;
cout << lvalue << endl;
short svalue = 22344;
cout << svalue << endl;
cout << "Size of int " << sizeof(int) << endl;
cout << "Size of short int: " << sizeof(short) << endl;
cout << "Size of long int: " << sizeof(long) << endl;
cout << "Size of unsigned int: " << sizeof(unsigned int) << endl;
unsigned int uvalue = 5345554;
cout << uvalue << endl;
return 0;
}
そして、私はそれを実行したとき、私はこれを取得:あなたが見ることができるように
568534534
22344
Size of int 4
Size of short int: 2
Size of long int: 4
Size of unsigned int: 4
5345554
を。 long、およびunsigned int = int。
これは私の唯一の問題ではありません。数字がどれほど大きくても「長い倍精度」では、常に負の値を出力します。 は、ここでは、コードです:
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float fvalue = 123.456789;
cout << sizeof(float) << endl;
cout << setprecision(20) << fixed << fvalue << endl;
double dvalue = 234.5554;
cout << setprecision(20) << fixed << dvalue << endl;
long double lvalue = 123.4;
cout << setprecision(20) << fixed << lvalue << endl;
return 0;
}
ここでの結果です:あなたが何かに問題がある見ることができるように
4
123.45678710937500000000
234.55539999999999000000
-18137553330312606000000000000000000000000000000000000
は、だから、
を(ところでゼロのほとんどを削除しました)。私はIDLEと として日食使用しています 私は64ビットシステム上でだけど、私は私のシステムのためのMinGW-W64をインストールしようとしたMINGW32 を使用していますが、どのように見つけることができませんでした...不可欠な基本については
C++は整数型のサイズをほとんど実装者に任せます[これを読んでください](http://en.cppreference.com/w/cpp/language/types#Integer_types)。 C++標準では、整数型が少なくともXビットであることのみを指定しています。すべての整数型は64ビットです。 – user4581301
あなたは本当に一度に一つの質問をするべきです。 – juanchopanza
C++では、 'INT_MAX'のようなCマクロの代わりに' std :: numeric_limits'を使うことができます。 –