# arithmetic

Published articles for arithmetic.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Your First Virtual Machine: Write yourself a compiler, Part IV

DevFeed: [Your First Virtual Machine: Write yourself a compiler, Part IV](<https://devfeed.tech/articles/your-first-virtual-machine-write-yourself-a-compiler-part-iv-38040.md>)

Original publisher: [Read original article](<https://nurkiewicz.com/2026/08/your-first-virtual-machine-write-yourself-a-compiler.html>)

Published: 2026-08-24T22:00:00Z

Content type: tutorial

Language: en

Sources: [Tomasz Nurkiewicz around Java and concurrency](<https://devfeed.tech/sources/tomasz-nurkiewicz-around-java-and-concurrency.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [bytecode](<https://devfeed.tech/tags/bytecode.md>), [clojure](<https://devfeed.tech/tags/clojure.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [feature](<https://devfeed.tech/tags/feature.md>), [go](<https://devfeed.tech/tags/go.md>), [interpreter](<https://devfeed.tech/tags/interpreter.md>), [reverse-polish-notation](<https://devfeed.tech/tags/reverse-polish-notation.md>), [stack](<https://devfeed.tech/tags/stack.md>), [virtual-machine](<https://devfeed.tech/tags/virtual-machine.md>), [vm](<https://devfeed.tech/tags/vm.md>), [writing-compiler](<https://devfeed.tech/tags/writing-compiler.md>)

### AI overview

This tutorial explains how to build a virtual machine that reads and executes a binary intermediate representation. It covers the instruction loop, operand stack, arithmetic operations, postfix notation, and how the resulting executable compares with JVM files and .NET assemblies.

### Source excerpt

In the previous article, we emitted an intermediate representation (IR) for our programming language that is easier to process than source code. However, we did not build a program that could read and execute that IR. Such a program is called a virtual machine. Technically, it's still an interpreter. But instead of interpreting source code, it interprets IR. Our IR is binary, compact, structured, and generally faster to interpret than the original source. Moreover, as you'll see later, the VM's instruction set can express programs that our source language cannot produce yet!

## Arithmetic interpreter: Write yourself a compiler, Part II

DevFeed: [Arithmetic interpreter: Write yourself a compiler, Part II](<https://devfeed.tech/articles/arithmetic-interpreter-write-yourself-a-compiler-part-ii-38036.md>)

Original publisher: [Read original article](<https://nurkiewicz.com/2026/07/arithmetic-interpreter-write-yourself-a-compiler.html>)

Published: 2026-07-21T22:00:00Z

Content type: tutorial

Language: en

Sources: [Tomasz Nurkiewicz around Java and concurrency](<https://devfeed.tech/sources/tomasz-nurkiewicz-around-java-and-concurrency.md>)

Topics: [Compiler](<https://devfeed.tech/topics/compiler.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Regular expression](<https://devfeed.tech/topics/regular-expression.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [go](<https://devfeed.tech/tags/go.md>), [intermediate](<https://devfeed.tech/tags/intermediate.md>), [interpreter](<https://devfeed.tech/tags/interpreter.md>), [operations](<https://devfeed.tech/tags/operations.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [writing-compiler](<https://devfeed.tech/tags/writing-compiler.md>)

### AI overview

This tutorial extends a simple arithmetic interpreter to support addition, subtraction, multiplication, and division. It updates the regular-expression parsing and interpreter logic, with a later installment planned to compile the language into an intermediate representation.

### Source excerpt

In the previous article, we created the most naive interpreter, which can basically execute number + number expressions. A logical extension is obviously to handle all basic operations: addition, subtraction, multiplication and division. The time has come!

## Packing Matrix-Vector Multiplication in Fully Homomorphic Encryption

DevFeed: [Packing Matrix-Vector Multiplication in Fully Homomorphic Encryption](<https://devfeed.tech/articles/packing-matrix-vector-multiplication-in-fully-homomorphic-encryption-40487.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2024/09/06/packing-matrix-vector-multiplication-in-fhe/>)

Published: 2024-09-07T04:18:09Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [homomorphic encryption](<https://devfeed.tech/topics/homomorphic-encryption.md>), [FHE](<https://devfeed.tech/topics/fhe.md>), [Encryption](<https://devfeed.tech/topics/encryption.md>), [layout](<https://devfeed.tech/topics/layout.md>), [parallel](<https://devfeed.tech/topics/parallel.md>), [Python](<https://devfeed.tech/topics/python.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [code](<https://devfeed.tech/tags/code.md>), [cryptography](<https://devfeed.tech/tags/cryptography.md>), [data](<https://devfeed.tech/tags/data.md>), [encryption](<https://devfeed.tech/tags/encryption.md>), [fhe](<https://devfeed.tech/tags/fhe.md>), [github-repository](<https://devfeed.tech/tags/github-repository.md>), [homomorphic-encryption](<https://devfeed.tech/tags/homomorphic-encryption.md>), [layout](<https://devfeed.tech/tags/layout.md>), [linear-algebra](<https://devfeed.tech/tags/linear-algebra.md>), [lwe](<https://devfeed.tech/tags/lwe.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [packing](<https://devfeed.tech/tags/packing.md>), [parallel](<https://devfeed.tech/tags/parallel.md>), [programming](<https://devfeed.tech/tags/programming.md>), [python](<https://devfeed.tech/tags/python.md>), [rlwe](<https://devfeed.tech/tags/rlwe.md>), [simd](<https://devfeed.tech/tags/simd.md>), [strategies](<https://devfeed.tech/tags/strategies.md>)

### AI overview

This article explains packing for SIMD-style fully homomorphic encryption. It describes how to arrange plaintext data in RLWE ciphertexts so matrix-vector multiplication requires fewer alignment multiplications and rotations, then introduces two basic packing techniques and a computational model.

### Source excerpt

In my recent overview of homomorphic encryption, I underemphasized the importance of data layout when working with arithmetic (SIMD-style) homomorphic encryption schemes. In the FHE world, the name given to data layout strategies is called "packing," because it revolves around putting multiple plaintext data into RLWE ciphertexts in carefully-chosen ways that mesh well with the operations you'd like to perform. By "mesh well" I mean it reduces the number of extra multiplications and rotations required merely to align data elements properly, rather than doing the actual computation you care about.

## Computing Percentages Easier

DevFeed: [Computing Percentages Easier](<https://devfeed.tech/articles/computing-percentages-easier-40472.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/09/05/computing-percentages-easier/>)

Published: 2023-09-05T21:47:37Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [math](<https://devfeed.tech/topics/math.md>), [Computing](<https://devfeed.tech/topics/computing.md>)

Tags: [approach](<https://devfeed.tech/tags/approach.md>), [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [math](<https://devfeed.tech/tags/math.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [numbers](<https://devfeed.tech/tags/numbers.md>), [puzzle](<https://devfeed.tech/tags/puzzle.md>), [scaling](<https://devfeed.tech/tags/scaling.md>)

### AI overview

A math tutorial explains mental percentage calculations using the fact that x% of y equals y% of x. It presents several approaches, including choosing the easier percentage, multiplying first and dividing by 100, scaling from 1%, and splitting the denominator.

### Source excerpt

Problem: Compute 16% of 25 in your head. Solution: 16% of 25 is equivalent to 25% of 16, which is clearly 4. This is true for all numbers: $x\%$ of $y$ is always equal to $y\%$ of $x$. The first one is $\frac{x}{100} y$ and the second is $\frac{y}{100}x$, and because multiplication is commutative and associative, both are equal to $(x \cdot y) / 100$. You can pick the version that is easiest.

## Two's Complement and Group Theory

DevFeed: [Two's Complement and Group Theory](<https://devfeed.tech/articles/two-s-complement-and-group-theory-40465.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/07/10/twos-complement-and-group-theory/>)

Published: 2023-07-10T07:00:00Z

Content type: article

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [math](<https://devfeed.tech/topics/math.md>), [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [Computer science](<https://devfeed.tech/topics/computer-science.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [abelian-groups](<https://devfeed.tech/tags/abelian-groups.md>), [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [bits](<https://devfeed.tech/tags/bits.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [circuits](<https://devfeed.tech/tags/circuits.md>), [computer-science](<https://devfeed.tech/tags/computer-science.md>), [group-actions](<https://devfeed.tech/tags/group-actions.md>), [groups](<https://devfeed.tech/tags/groups.md>), [math](<https://devfeed.tech/tags/math.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [programming](<https://devfeed.tech/tags/programming.md>), [quotients](<https://devfeed.tech/tags/quotients.md>), [symmetry](<https://devfeed.tech/tags/symmetry.md>), [twos-complement](<https://devfeed.tech/tags/twos-complement.md>)

### AI overview

The article explains two's-complement signed integer arithmetic using group theory. It presents signed and unsigned n-bit integers as representations of the quotient group of integers modulo 2^n, clarifying why the same arithmetic circuits can operate on both.

### Source excerpt

Before I discovered math, I was a first year undergrad computer science student taking Electrical Engineering 101. The first topic I learned was what bits and boolean gates are, and the second was the two's complement representation of a negative n-bit integer. At the time two's complement seemed to me like a bizarre quirk of computer programming, with minutiae you just had to memorize. If the leading bit is 1, it's negative, and otherwise it's positive.

## Operator overloading in Kotlin

DevFeed: [Operator overloading in Kotlin](<https://devfeed.tech/articles/operator-overloading-in-kotlin-39338.md>)

Original publisher: [Read original article](<https://kt.academy/article/kfde-operators>)

Published: 2023-01-23T00:01:00Z

Content type: tutorial

Language: en

Sources: [Kt. Academy](<https://devfeed.tech/sources/kt-academy.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Code](<https://devfeed.tech/topics/code.md>), [class](<https://devfeed.tech/topics/class.md>), [function](<https://devfeed.tech/topics/function.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Math and Logic](<https://devfeed.tech/topics/math-and-logic.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [class](<https://devfeed.tech/tags/class.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [complex-numbers](<https://devfeed.tech/tags/complex-numbers.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [extension-function](<https://devfeed.tech/tags/extension-function.md>), [function](<https://devfeed.tech/tags/function.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [number](<https://devfeed.tech/tags/number.md>), [numbers](<https://devfeed.tech/tags/numbers.md>), [operations](<https://devfeed.tech/tags/operations.md>), [operator-overloading](<https://devfeed.tech/tags/operator-overloading.md>), [physics](<https://devfeed.tech/tags/physics.md>), [type](<https://devfeed.tech/tags/type.md>), [types](<https://devfeed.tech/tags/types.md>), [workshop-learning-programming](<https://devfeed.tech/tags/workshop-learning-programming.md>)

### AI overview

A tutorial on Kotlin operator overloading. It explains Kotlin's predefined operators, how operator methods are declared for custom classes, and how arithmetic and range operators are handled, using complex numbers as an example.

### Source excerpt

How are operators defined for types in Kotlin, and how can we define our own operators.

## The Inner Product as a Decision Rule

DevFeed: [The Inner Product as a Decision Rule](<https://devfeed.tech/articles/the-inner-product-as-a-decision-rule-40410.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2017/05/22/the-inner-product-as-a-decision-rule/>)

Published: 2017-05-22T08:00:00Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [math](<https://devfeed.tech/topics/math.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [inner-product](<https://devfeed.tech/tags/inner-product.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [linear-algebra](<https://devfeed.tech/tags/linear-algebra.md>), [machine-learning](<https://devfeed.tech/tags/machine-learning.md>), [math](<https://devfeed.tech/tags/math.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [programming](<https://devfeed.tech/tags/programming.md>), [projection](<https://devfeed.tech/tags/projection.md>), [support-vector-machines](<https://devfeed.tech/tags/support-vector-machines.md>), [vectors](<https://devfeed.tech/tags/vectors.md>)

### AI overview

This article explains how the standard inner product, or dot product, acts as a geometric decision rule. It shows how the sign of the product determines which side of a line through the origin a vector lies on, while zero indicates that the vector lies on the line. The explanation connects this behavior to vector projection.

### Source excerpt

The standard inner product of two vectors has some nice geometric properties. Given two vectors $ x, y \in \mathbb{R}^n$, where by $ x_i$ I mean the $ i$-th coordinate of $ x$, the standard inner product (which I will interchangeably call the dot product) is defined by the formula $$\displaystyle \langle x, y \rangle = x_1 y_1 + \dots + x_n y_n$$ This formula, simple as it is, produces a lot of interesting geometry.

## Connecting Elliptic Curves with Finite Fields

DevFeed: [Connecting Elliptic Curves with Finite Fields](<https://devfeed.tech/articles/connecting-elliptic-curves-with-finite-fields-40352.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2014/03/19/connecting-elliptic-curves-with-finite-fields-a-reprise/>)

Published: 2014-03-19T10:00:05Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [Algorithm](<https://devfeed.tech/topics/algorithm.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [algorithm](<https://devfeed.tech/tags/algorithm.md>), [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [code](<https://devfeed.tech/tags/code.md>), [elliptic-curves](<https://devfeed.tech/tags/elliptic-curves.md>), [fields](<https://devfeed.tech/tags/fields.md>), [finite-fields](<https://devfeed.tech/tags/finite-fields.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>)

### AI overview

A tutorial connecting elliptic-curve arithmetic over rational numbers with finite-field arithmetic. It combines previously developed programs and discusses the mathematical background, point addition, finite-field representations, and subtle limitations when applying the code across finite fields.

### Source excerpt

So here we are. We've studied the general properties of elliptic curves, written a program for elliptic curve arithmetic over the rational numbers, and taken a long detour to get some familiarity with finite fields (the mathematical background and a program that implements arbitrary finite field arithmetic). And now we want to get back on track and hook our elliptic curve program up with our finite field program to make everything work.

## Infinitely Many Primes (Using Topology)

DevFeed: [Infinitely Many Primes (Using Topology)](<https://devfeed.tech/articles/infinitely-many-primes-using-topology-40287.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2012/09/26/infinitely-many-primes-using-topology/>)

Published: 2012-09-26T11:51:28Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Sequences](<https://devfeed.tech/topics/sequences.md>), [structure](<https://devfeed.tech/topics/structure.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [numbers](<https://devfeed.tech/tags/numbers.md>), [primes](<https://devfeed.tech/tags/primes.md>), [sequence](<https://devfeed.tech/tags/sequence.md>), [using](<https://devfeed.tech/tags/using.md>)

### AI overview

A proof that there are infinitely many prime numbers using a topology on the integers whose basis consists of two-sided arithmetic progressions. Assuming finitely many primes leads to a finite open complement, contradicting the fact that no finite set is open in this topology.

### Source excerpt

Problem: Prove there are infinitely many prime numbers. Solution: First recall that an arithmetic progression with difference $ d$ is a sequence of integers $ a_n \subset \mathbb{Z}$ so that for every pair $ a_k, a_{k+1}$ the difference $ a_{k+1} - a_k = d$. We proceed be defining a topology on the set of integers by defining a basis $ B$ of unbounded (in both directions) arithmetic progressions. That is, an open set in this topology is an arbitrary union of arithmetic progressions from $ -\infty$ to $ \infty$.

## N Choose 2 is the Sum of the First N-1 Integers

DevFeed: [N Choose 2 is the Sum of the First N-1 Integers](<https://devfeed.tech/articles/n-choose-2-is-the-sum-of-the-first-n-1-integers-40243.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2011/10/02/n-choose-2/>)

Published: 2011-10-02T16:16:47Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [Mathematics](<https://devfeed.tech/topics/mathematics.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [bijections](<https://devfeed.tech/tags/bijections.md>), [combinatorics](<https://devfeed.tech/tags/combinatorics.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [proofs-without-words](<https://devfeed.tech/tags/proofs-without-words.md>)

### AI overview

A combinatorial bijection shows that the binomial coefficient n choose 2 equals the sum of the first n−1 integers. The article explains how yellow dots correspond uniquely to pairs of dots in the bottom row, then briefly connects bijections to isomorphism and classification in mathematics.

### Source excerpt

Problem: Determine an arithmetic expression for $ \binom{n}{2}$. Solution: The following picture describes a bijection between the set of yellow dots and the set of pairs of purple dots: In particular, selecting any yellow dots and travelling downward along diagonals gives a unique pair of blue dots. Conversely, picking any pair of blue dots gives a unique yellow dot which is the meeting point (the "peak") of the inward diagonals. If we say the bottom row has $ n$ elements, then the number of yellow dots is clearly $ 1 + 2 + \dots + (n-1)$, and the number of pairs in the last row is just $ \binom{n}{2}$.

## Number Theory--A Primer

DevFeed: [Number Theory--A Primer](<https://devfeed.tech/articles/number-theory-a-primer-40235.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2011/07/30/number-theory-a-primer/>)

Published: 2011-07-30T15:03:38Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [primes](<https://devfeed.tech/topics/primes.md>), [Cryptography](<https://devfeed.tech/topics/cryptography.md>), [Encryption](<https://devfeed.tech/topics/encryption.md>)

Tags: [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [encryption](<https://devfeed.tech/tags/encryption.md>), [factoring](<https://devfeed.tech/tags/factoring.md>), [gcd](<https://devfeed.tech/tags/gcd.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [number](<https://devfeed.tech/tags/number.md>), [number-theory](<https://devfeed.tech/tags/number-theory.md>), [primer](<https://devfeed.tech/tags/primer.md>), [primes](<https://devfeed.tech/tags/primes.md>), [programming](<https://devfeed.tech/tags/programming.md>), [rsa](<https://devfeed.tech/tags/rsa.md>)

### AI overview

A primer on elementary number theory covering integers, divisibility, composite and prime numbers, prime factorization, and the greatest common divisor. It provides background for a separate post on RSA encryption.

### Source excerpt

This primer exists for the background necessary to read our post on RSA encryption, but it also serves as a general primer to number theory. Oh, Numbers, Numbers, Numbers We start with some easy definitions. Definition: The set of integers, denoted $ \mathbb{Z}$, is the set $ \left \{ \dots -2, -1, 0, 1, 2, \dots \right \}$. Definition: Let $ a,b$ be integers, then $ a$ divides $ b$, denoted $ a \mid b$, if there exists an integer $ n$ such that $ na = b$.