{"id":18839259,"url":"https://github.com/solareenlo/42cpp-module-06","last_synced_at":"2026-07-14T09:32:34.642Z","repository":{"id":93865658,"uuid":"374261342","full_name":"solareenlo/42cpp-module-06","owner":"solareenlo","description":"C++ practice 06 (sttaic_cast, reinterpret_cast, dynamic_cast)","archived":false,"fork":false,"pushed_at":"2021-06-10T09:03:40.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-27T00:41:38.665Z","etag":null,"topics":["42","42born2code","42cursus","42projects","cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/solareenlo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-06T03:45:18.000Z","updated_at":"2021-06-10T09:03:43.000Z","dependencies_parsed_at":"2023-03-08T12:45:42.373Z","dependency_job_id":null,"html_url":"https://github.com/solareenlo/42cpp-module-06","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/solareenlo/42cpp-module-06","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solareenlo%2F42cpp-module-06","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solareenlo%2F42cpp-module-06/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solareenlo%2F42cpp-module-06/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solareenlo%2F42cpp-module-06/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/solareenlo","download_url":"https://codeload.github.com/solareenlo/42cpp-module-06/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/solareenlo%2F42cpp-module-06/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35455901,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-14T02:00:06.603Z","response_time":114,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42born2code","42cursus","42projects","cpp"],"created_at":"2024-11-08T02:42:33.817Z","updated_at":"2026-07-14T09:32:34.622Z","avatar_url":"https://github.com/solareenlo.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 42cpp-module-06\n\n### ex02\n- [dynamic_cast](https://en.cppreference.com/w/cpp/language/dynamic_cast)\n- [ダウンキャスト(dynamic_cast)](http://yohshiy.blog.fc2.com/blog-entry-15.html)\n\n### ex01\n- [C++と 4 つのキャスト演算](https://www.yunabe.jp/docs/cpp_casts.html)\n  - static_cast: 暗黙の型変換が行われることを明示的に示す演算子\n  - dynamic_cast: base class のポインタを derived class のポインタにキャストする演算子\n  - reinterpret_cast: ポインタ型を他のポインタ型に強制的に変換する演算子\n    - または，整数型を任意の型のポインタに変換する演算子\n  - const_cast: ポインタ型，参照型の const や volatile を無効化する演算子\n\n### ex00\n#### 方針\n- `-inf` \u003c `-DBL_MAX` \u003c `-inff` \u003c `-FLT_MAX` \u003c `INT_MIN` \u003c `CHR_MIN` \u003c `-FLT_MIN` \u003c `-DBL_MIN` \u003c `0` \u003c `DBL_MIN` \u003c `FLT_MIN` \u003c `CHR_MIN` \u003c `INT_MAX` \u003c `FLT_MAX` \u003c `+inff` \u003c `DBL_MAX` \u003c `+inf`\n- このような大小関係で `char`, `int`, `float`, `double` に値を設定したり，キャストしたりした場合に範囲外になるとエラーにした\n- `int` にキャストした場合は小数点以下が切り捨て\n- `nan`, `+nan`, `-nan`, `nanf`, `+nanf`, `-nanf` は例外処理\n- long は `2^24` までしか整数を正しく保存することができない\n  - 仮数部が 23 bit までしかないので\n- double は `2^53` までしか整数を正しく保存することができない\n  - 仮数部が 52 bit までしかないので\n\n#### 小数点の桁数表示\n- [【C++】小数点の桁数を指定する方法と注意点【cout／iostream】](https://marycore.jp/prog/cpp/stream-format-float/)\n\n#### float\n- [Convert INT_MAX to float and then back to integer.](https://stackoverflow.com/questions/23420783/convert-int-max-to-float-and-then-back-to-integer/23423240)\n- [int to float conversion produces a warning?](https://stackoverflow.com/questions/7775129/int-to-float-conversion-produces-a-warning)\n- [FLP34-C. 浮動小数点の型変換は変換後の型の範囲に収まるようにする](https://www.jpcert.or.jp/sc-rules/c-flp34-c.html)\n- [浮動小数点数型と誤差 float 型](https://www.cc.kyoto-su.ac.jp/~yamada/programming/float.html)\n```c++\nfor (int a = 16777210; a \u003c 16777224; a++) {\n    float b = a;\n    int c = b;\n    std::cout \u003c\u003c \"a=\" \u003c\u003c a;\n    std::cout \u003c\u003c \" c=\" \u003c\u003c c;\n    std::cout \u003c\u003c \" b=0x\" \u003c\u003c std::bitset\u003c32\u003e(b) \u003c\u003c std::endl;\n}\n```\n```shell\na=16777210 c=16777210 b=0x00000000111111111111111111111010\na=16777211 c=16777211 b=0x00000000111111111111111111111011\na=16777212 c=16777212 b=0x00000000111111111111111111111100\na=16777213 c=16777213 b=0x00000000111111111111111111111101\na=16777214 c=16777214 b=0x00000000111111111111111111111110\na=16777215 c=16777215 b=0x00000000111111111111111111111111\na=16777216 c=16777216 b=0x00000001000000000000000000000000\na=16777217 c=16777216 b=0x00000001000000000000000000000000\na=16777218 c=16777218 b=0x00000001000000000000000000000010\na=16777219 c=16777220 b=0x00000001000000000000000000000100\na=16777220 c=16777220 b=0x00000001000000000000000000000100\na=16777221 c=16777220 b=0x00000001000000000000000000000100\na=16777222 c=16777222 b=0x00000001000000000000000000000110\na=16777223 c=16777224 b=0x00000001000000000000000000001000\n```\n```c++\nfor (int a = -16777224; a \u003c -16777210; a++) {\n    float b = a;\n    int c = b;\n    std::cout \u003c\u003c \"a=\" \u003c\u003c a;\n    std::cout \u003c\u003c \" c=\" \u003c\u003c c;\n    std::cout \u003c\u003c \" b=0x\" \u003c\u003c std::bitset\u003c32\u003e(b) \u003c\u003c std::endl;\n}\n```\n```shell\na=-16777224 c=-16777224 b=0x11111110111111111111111111111000\na=-16777223 c=-16777224 b=0x11111110111111111111111111111000\na=-16777222 c=-16777222 b=0x11111110111111111111111111111010\na=-16777221 c=-16777220 b=0x11111110111111111111111111111100\na=-16777220 c=-16777220 b=0x11111110111111111111111111111100\na=-16777219 c=-16777220 b=0x11111110111111111111111111111100\na=-16777218 c=-16777218 b=0x11111110111111111111111111111110\na=-16777217 c=-16777216 b=0x11111111000000000000000000000000\na=-16777216 c=-16777216 b=0x11111111000000000000000000000000\na=-16777215 c=-16777215 b=0x11111111000000000000000000000001\na=-16777214 c=-16777214 b=0x11111111000000000000000000000010\na=-16777213 c=-16777213 b=0x11111111000000000000000000000011\na=-16777212 c=-16777212 b=0x11111111000000000000000000000100\na=-16777211 c=-16777211 b=0x11111111000000000000000000000101\n```\n\n#### union\n- [Can a union be initialized in the declaration?](https://stackoverflow.com/questions/2148989/can-a-union-be-initialized-in-the-declaration)\n\n#### max, min\n- [std::numeric_limits](https://cpprefjp.github.io/reference/limits/numeric_limits.html)\n\n#### 型変換\n- [strtol](http://www9.plala.or.jp/sgwr-t/lib/strtol.html)\n- [strtod](http://www9.plala.or.jp/sgwr-t/lib/strtod.html)\n- INT_MIN, INT_MAX は C++03, C++11 から\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolareenlo%2F42cpp-module-06","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsolareenlo%2F42cpp-module-06","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsolareenlo%2F42cpp-module-06/lists"}