#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Demonstratie van representatiefouten met binaire floating point. Hoofdstuk: 29 — Decimalen in Python & C """ a = 0.1 b = 0.2 c = a + b print("a =", a) print("b =", b) print("a + b =", c) print("Is a + b exact gelijk aan 0.3?", c == 0.3) print("Verschil:", c - 0.3) print("Afgerond op 1 decimaal:", round(c, 1))