{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "653a0a70",
   "metadata": {},
   "source": [
    "# 04-13 · 0.1 + 0.2 — badamy przybliżenie\n",
    "\n",
    "Praktyka do sekcji [„Dlaczego 0,1 + 0,2 nie jest równe 0,3”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3b9fc192",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zobaczyć błąd float na własne oczy i zrozumieć, że jest wytłumaczalny."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8368fd69",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "16945dac",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:38.121938Z",
     "iopub.status.busy": "2026-08-16T10:03:38.121829Z",
     "iopub.status.idle": "2026-08-16T10:03:38.145595Z",
     "shell.execute_reply": "2026-08-16T10:03:38.145155Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.30000000000000004\n"
     ]
    }
   ],
   "source": [
    "print(0.1 + 0.2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23e0978b",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Sprawdź, co naprawdę jest przechowywane za 0.1."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ab673a6a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:38.146832Z",
     "iopub.status.busy": "2026-08-16T10:03:38.146722Z",
     "iopub.status.idle": "2026-08-16T10:03:38.148977Z",
     "shell.execute_reply": "2026-08-16T10:03:38.148578Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(3602879701896397, 36028797018963968)\n"
     ]
    }
   ],
   "source": [
    "print((0.1).as_integer_ratio())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce1320eb",
   "metadata": {},
   "source": [
    "## Eksperyment 2\n",
    "\n",
    "Przewidź: czy będzie `0.5 + 0.25` równa dokładnie `0.75`? Sprawdź — czasem suma wychodzi dokładna."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9949da8a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:38.149955Z",
     "iopub.status.busy": "2026-08-16T10:03:38.149850Z",
     "iopub.status.idle": "2026-08-16T10:03:38.152041Z",
     "shell.execute_reply": "2026-08-16T10:03:38.151603Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "print(0.5 + 0.25 == 0.75)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "38806756",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Sprawdź `1.1 + 2.2` — czy jest równe dokładnie `3.3`?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e1818f59",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T10:03:38.153014Z",
     "iopub.status.busy": "2026-08-16T10:03:38.152913Z",
     "iopub.status.idle": "2026-08-16T10:03:38.154934Z",
     "shell.execute_reply": "2026-08-16T10:03:38.154569Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.3000000000000003\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "print(1.1 + 2.2)\n",
    "print(1.1 + 2.2 == 3.3)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
