Last active
August 29, 2015 14:21
-
-
Save MasazI/a6255d835b95bb41baf1 to your computer and use it in GitHub Desktop.
limits.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// limits.cpp | |
// CplusplusPractice | |
// | |
// Created by masai on 2015/05/19. | |
// Copyright (c) 2015年 masai. All rights reserved. | |
// | |
#include <iostream> | |
#include <limits> | |
typedef long HashValueLong; | |
typedef unsigned long HashValueULong; | |
int main(int argc, const char * argv[]) { | |
// マクロ定義による取得 | |
std::cout << "int max: " << INT_MAX << std::endl; | |
std::cout << "int min: " << INT_MIN << std::endl; | |
// クラステンプレートによる取得 | |
std::cout << "int max: " << std::numeric_limits<int>::max() << std::endl; //2147483647 | |
std::cout << "long max: " << std::numeric_limits<long>::max() << std::endl; //2147483647 | |
// 型に依存しない書き方 | |
std::cout << "HashValue(long): " << std::numeric_limits<HashValueLong>::max() << std::endl; | |
std::cout << "HashValue(unsigned long): " << std::numeric_limits<HashValueULong>::max() << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment