{ "cells": [ { "cell_type": "markdown", "id": "dt-0", "metadata": {}, "source": "# Data types and operators\n\nA tour of numbl's scalar types and operators." }, { "cell_type": "markdown", "id": "dt-1", "metadata": {}, "source": "## Numbers and arithmetic" }, { "cell_type": "code", "id": "dt-2", "metadata": {}, "execution_count": null, "outputs": [], "source": "x = 3.5;\ny = 2;\n[x + y, x - y, x * y, x / y]\nx ^ y\nmod(7, 3)" }, { "cell_type": "markdown", "id": "dt-3", "metadata": {}, "source": "## Logical values and comparisons" }, { "cell_type": "code", "id": "dt-4", "metadata": {}, "execution_count": null, "outputs": [], "source": "v = [1 2 3 4 5];\nv > 2\nv == 3\nany(v > 4)\nall(v > 0)" }, { "cell_type": "code", "id": "dt-5", "metadata": {}, "execution_count": null, "outputs": [], "source": "t = true; f = false;\n[t && f, t || f, xor(t, f), ~t]" }, { "cell_type": "markdown", "id": "dt-6", "metadata": {}, "source": "## Complex numbers" }, { "cell_type": "code", "id": "dt-7", "metadata": {}, "execution_count": null, "outputs": [], "source": "z = 3 + 4i;\nabs(z)\nangle(z)\n[real(z), imag(z)]\nconj(z)" }, { "cell_type": "markdown", "id": "dt-8", "metadata": {}, "source": "## Constants, special values, and rounding" }, { "cell_type": "code", "id": "dt-9", "metadata": {}, "execution_count": null, "outputs": [], "source": "[pi, exp(1), eps]\n[1/0, -1/0, 0/0]\n[isnan(0/0), isinf(1/0)]" }, { "cell_type": "code", "id": "dt-10", "metadata": {}, "execution_count": null, "outputs": [], "source": "[round(2.5), floor(-2.3), ceil(2.1), fix(-2.7), sign(-3)]" } ], "metadata": { "kernelspec": { "display_name": "numbl (MATLAB syntax)", "language": "numbl", "name": "numbl" }, "language_info": { "codemirror_mode": "octave", "file_extension": ".m", "mimetype": "text/x-octave", "name": "numbl", "nbconvert_exporter": "script", "pygments_lexer": "matlab" } }, "nbformat": 4, "nbformat_minor": 5 }