{"id":24105087,"url":"https://github.com/nigeparis/42-cpp-02","last_synced_at":"2026-02-15T15:43:46.773Z","repository":{"id":271722625,"uuid":"905779239","full_name":"NigeParis/42-cpp-02","owner":"NigeParis","description":"The Fantastic Four! 👑  To join the club, each class must feature these four superstar members:      Default constructor (The magic opener 🪄)     Copy constructor (The clone master 🧬)     Copy assignment operator (The switcheroo artist 🔄)     Destructor (The clean-up crew 🧹)","archived":false,"fork":false,"pushed_at":"2025-01-09T13:21:28.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-09T14:35:31.069Z","etag":null,"topics":["cpp","cpp-learning","cpp98"],"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/NigeParis.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":"2024-12-19T14:01:57.000Z","updated_at":"2025-01-09T13:22:56.000Z","dependencies_parsed_at":"2025-01-09T14:35:32.760Z","dependency_job_id":"9d1a9210-2a19-4a3b-b5f3-bfd4426ddd83","html_url":"https://github.com/NigeParis/42-cpp-02","commit_stats":null,"previous_names":["nigeparis/42-cpp-02"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NigeParis%2F42-cpp-02","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NigeParis%2F42-cpp-02/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NigeParis%2F42-cpp-02/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NigeParis%2F42-cpp-02/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NigeParis","download_url":"https://codeload.github.com/NigeParis/42-cpp-02/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241072722,"owners_count":19904829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cpp","cpp-learning","cpp98"],"created_at":"2025-01-10T20:25:15.287Z","updated_at":"2025-10-03T19:08:34.687Z","avatar_url":"https://github.com/NigeParis.png","language":"C++","readme":"Of course! Here's the revised version without emojis:\n\n# New Class Code Playbook\n\n## 1. Welcome to the Orthodox Canonical Form Club!\nFrom now on, all your classes must join the exclusive ranks of the Orthodox Canonical Form, unless you receive special clearance otherwise.\n\n## 2. The Fantastic Four!\nTo join the club, each class must feature these four superstar members:\n- **Default constructor** (The magic opener)\n- **Copy constructor** (The clone master)\n- **Copy assignment operator** (The switcheroo artist)\n- **Destructor** (The clean-up crew)\n\n## 3. Divide and Conquer!\n- **Header file (.hpp/.h):** Contains the class's royal decree (definition).\n- **Source file (.cpp):** Implements the class's grand plan (implementation).\n\n\n## Step 1: The Basics\nUp until now, you've been working with:\n- **Integers** and their buddies (short, char, long, etc.)\n- **Floating-point numbers** and their cousins (float, double, etc.)\n\nThese have been your go-to number types in coding.\n\n## Step 2: Opposite Characteristics\nIntegers and floating-point numbers couldn't be more different in their characteristics. It’s a classic case of opposites attract.\n\n## Step 3: Meet the Game Changer\nIntroducing **fixed-point numbers**—your new best friend in coding! Fixed-point numbers strike the perfect balance between:\n- **Performance**\n- **Accuracy**\n- **Range**\n- **Precision**\n\n## Why Should You Care?\nFixed-point numbers are particularly useful in:\n- **Computer graphics**: For flawless visual calculations.\n- **Sound processing**: Keeping your audio crisp and clear.\n\n# Exercises for Fixed-Point Number Class\n\n## Exercise 00: My First Class in Orthodox Canonical Form\n\n### The Journey Begins\nYour first steps into the world of class design were promising, but our class currently represents a grand total of... 0.0. Time to spice things up!\n\n\n## Exercise 01: Towards a More Useful Fixed-Point Number Class\n\n### Enhancing the Foundation\nOur previous class was a humble beginning, but let's push its boundaries. Here’s how to level up:\n\n### Constructor Upgrades\n- **Integer Constructor**: Transforms a constant integer into a fixed-point value with 8 fractional bits.\n   ```cpp\n   Fixed(const int value);\n   ```\n- **Floating-Point Constructor**: Converts a constant floating-point number into a fixed-point value with 8 fractional bits.\n   ```cpp\n   Fixed(const float value);\n   ```\n\n### Transformation Skills\n- **Convert to Float**: `float toFloat(void) const;` Transforms the fixed-point value into a floating-point value.\n   ```cpp\n   float toFloat(void) const;\n   ```\n- **Convert to Int**: `int toInt(void) const;` Transforms the fixed-point value into an integer value.\n   ```cpp\n   int toInt(void) const;\n   ```\n\n### Stream Magic\nAdd an overload of the insertion (`\u003c\u003c`) operator to insert a floating-point representation of the fixed-point number into the output stream object passed as a parameter.\n   ```cpp\n   friend std::ostream \u0026operator\u003c\u003c(std::ostream \u0026out, const Fixed \u0026fixed);\n   ```\n\n## Exercise 02: Now We’re Talking\n\n### Operator Overload Party\nAdd public member functions to overload these operators:\n- **Comparison Operators**: `\u003e`, `\u003c`, `\u003e=`, `\u003c=`, `==`, and `!=`.\n   ```cpp\n   bool operator\u003e(const Fixed \u0026other) const;\n   bool operator\u003c(const Fixed \u0026other) const;\n   bool operator\u003e=(const Fixed \u0026other) const;\n   bool operator\u003c=(const Fixed \u0026other) const;\n   bool operator==(const Fixed \u0026other) const;\n   bool operator!=(const Fixed \u0026other) const;\n   ```\n- **Arithmetic Operators**: `+`, `-`, `*`, and `/`.\n   ```cpp\n   Fixed operator+(const Fixed \u0026other) const;\n   Fixed operator-(const Fixed \u0026other) const;\n   Fixed operator*(const Fixed \u0026other) const;\n   Fixed operator/(const Fixed \u0026other) const;\n   ```\n- **Increment/Decrement Operators**: Pre-increment, post-increment, pre-decrement, and post-decrement, adjusting the fixed-point value by the smallest representable ϵ.\n   ```cpp\n   Fixed \u0026operator++();      // Pre-increment\n   Fixed operator++(int);    // Post-increment\n   Fixed \u0026operator--();      // Pre-decrement\n   Fixed operator--(int);    // Post-decrement\n   ```\n\n### Superpowers: Min and Max\nAdd these public overloaded member functions to your class:\n- **Static Min**: Takes two references to fixed-point numbers and returns a reference to the smallest one.\n   ```cpp\n   static Fixed \u0026min(Fixed \u0026a, Fixed \u0026b);\n   ```\n- **Static Min (Const)**: Takes two references to constant fixed-point numbers and returns a reference to the smallest one.\n   ```cpp\n   static const Fixed \u0026min(const Fixed \u0026a, const Fixed \u0026b);\n   ```\n- **Static Max**: Takes two references to fixed-point numbers and returns a reference to the greatest one.\n   ```cpp\n   static Fixed \u0026max(Fixed \u0026a, Fixed \u0026b);\n   ```\n- **Static Max (Const)**: Takes two references to constant fixed-point numbers and returns a reference to the greatest one.\n   ```cpp\n   static const Fixed \u0026max(const Fixed \u0026a, const Fixed \u0026b);\n   ```\n\n## Exercise 03: BSP - Bonus\n\n### Putting It All Together\nNow that your Fixed class is fully functional, let’s put it to use! Implement a function that indicates whether a point is inside a triangle or not.\n\n```cpp\nbool    bsp( Point const a, Point const b, Point const c, Point const point) {\n\n   //code\n}\n\n```\n\n![Screenshot from 2025-01-09 14-03-46](https://github.com/user-attachments/assets/f3dad5c3-11b3-4065-8e83-1a2bb397c633)\n\n![Screenshot from 2025-01-09 14-04-09](https://github.com/user-attachments/assets/a0d2e0e5-fce3-4a74-8b07-7117d0f1ed16)\n\n![Screenshot from 2025-01-09 14-04-27](https://github.com/user-attachments/assets/7b06b120-04bd-4a27-9a7c-66eab7d2b85d)\n\n- **Scientific programming**: Ensuring your data remains spot on.\n\nFixed-point numbers are here to elevate your coding game.\nEmbrace the change and enjoy the ride!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnigeparis%2F42-cpp-02","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnigeparis%2F42-cpp-02","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnigeparis%2F42-cpp-02/lists"}