{ "cells": [ { "cell_type": "markdown", "source": [ "# Rational numbers\n", "\n", "In julia rational numbers can be constructed with the `//` operator.\n", "Lets define two rational numbers, `x` and `y`:" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "1//3" }, "metadata": {}, "execution_count": 1 } ], "cell_type": "code", "source": [ "x = 1//3" ], "metadata": {}, "execution_count": 1 }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "2//5" }, "metadata": {}, "execution_count": 2 } ], "cell_type": "code", "source": [ "y = 2//5" ], "metadata": {}, "execution_count": 2 }, { "cell_type": "markdown", "source": [ "When adding `x` and `y` together we obtain a new rational number:" ], "metadata": {} }, { "outputs": [ { "output_type": "execute_result", "data": { "text/plain": "11//15" }, "metadata": {}, "execution_count": 3 } ], "cell_type": "code", "source": [ "z = x + y" ], "metadata": {}, "execution_count": 3 }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.6.1" }, "kernelspec": { "name": "julia-1.6", "display_name": "Julia 1.6.1", "language": "julia" } }, "nbformat": 4 }