Floating point arithmetic types in C++ for any size and any base
Since there is so much interest on HN in floats lately and their software implementations, I wanted to show mine. It has no use and is just for teaching me floats and C++. Give me your thoughts.
Floating point arithmetic types in C++ for any size and any base launched on October 18, 2024 with 79 votes, #597 of 5,185 launches that month and more than 90% of that year's launches. The site was still online in September 2026, 2 years on.
In plain words
This is a C++ library implementing floating point arithmetic types that support arbitrary sizes and number bases. It was created as a learning project to explore how floating point numbers work and to develop C++ skills. The project is educational in nature with no practical applications, hosted on GitHub for review and feedback from the programming community.
written from the facts on this page · September 2026
From the sources
A floating point arithmetic which works with types of any mantissa, exponent or base in modern header-only C++. - clemensmanert/fas
fas is floating point arithmetic for arbitrary mantissa and exponent types in modern header-only C++ . It lets you construct various different float types using template parameters for the mantissa, exponent and base. The constructed float-types look and fell like a native float/double for arithmetic operations. Furthermore all methods are performed on the stack and do not require any heap space. fas::Float< int16_t , int8_t > f; This will result in a float using a signed 16 bit mantissa and a signed 8 bit exponent. fas::Float< int16_t , int8_t > f1 = 10 ; auto f2 = f1; f2 = -f1; // => -10 f2 = f1 + 10 ; // => 20 f2 = f1 - f1; // => 0 f2 = f1 * f1; // => 100 f2 = f1 / 20 ; // => 0.5 f2 += 1…from github.com
Does a similar job
all alternatives →
Kotlin Money2024 · blog.eriksen.com.br · ▲427Manipulating monetary amounts is a common computing chore. However, no mainstream language has a first-class data type for representing money, it’s up to programmers to code abstractions for it. This isn’t an issue per se until dealing with rounding issues from operations like installment payments (e.g., buy now, pay later), foreign exchange, or even simple things like fee processing and tax collection. Inspired by my days at N26 Brasil dealing with these challenges, I introduce Money: a Kotlin library that makes monetary calculations and allocations easy.
Sum (algebraic) types for C in one 100 line header2024 · github.com · ▲92A mirror of https://git.sr.ht/~grego/sumtypes.h. Contribute to grego/sumtype.h development by creating an account on GitHub.
Fast Random Library for C++172025 · github.com · ▲52Morning HN. Random number generation feels is a somewhat underrepresented topic in the C++ realm. There is a lot of questionable info about it found online and even the standard library is quite behind the times in terms of it's algorithms. It suffers from trying to accommodate sometimes impractical standard requirements and has several ways of getting significantly bad statistical results. This leaves a lot easily achievable performance & quality on the table. So, being a mathematician who mostly works with stochastic models and wants these models to run fast and well, I embarked on a…
dnum − A small TypeScript library to handle decimal numbers2023 · github.com · ▲42🧮 Small library for big decimal numbers. Contribute to bpierre/dnum development by creating an account on GitHub.
- HTHow to program in Rust as if it was old school C++ with pointers2022 · ▲24
Basically wrap your data struct in Option>> Better yet, use your custom type that provides few helper functions that make using it as nice as old C++ pointers. Obviously there's no pointer arithmetic, but it works great for dynamically allocated structures like trees or linked lists. Please comment how it's a horrible idea that will bring doom to me and my family. fn main() { struct Data { pub number: i32 } // struct Data { int number; }; let mut p:Pointer = Pointer(None); // Data *p = NULL; println!("{}", p.is_none()); // printf(p == NULL ? "true\n" :…
Build your own programming language in C++2021 · github.com · ▲94A minimal viable programming language on top of liblgpp - codr7/alang
More life & fun this month
the category →
A free city-building game in your browser. You are the mayor. You know what the city needs. Now get it past the zoning board, the neighbors, the appeals court and the next election.
Life & fun · 2d ago · permit.petercai.com
- IV
Life & fun · 15d ago · tanzaniaeducationproject.org

Turn a phone, tablet or TV into a sign. Type a message and it fills the screen: welcome signs, timers, Wi-Fi passwords and more. No app, no account, free.
Life & fun · 16d ago · bigwords.page

Play a free virtual guitar online with your keyboard or by touch. Slow songs down and see every chord, string and strum. Acoustic, classic, electric and bass.
Life & fun · 9d ago · guitoro.com

Carrier settings from iPhone, Pixel and Galaxy firmware, decoded and compared: APNs, VoLTE, 5G and Wi-Fi Calling per carrier, and what each build changed.
Life & fun · 13d ago · carrierexplode.com

Life & fun · 23d ago · space.bl2.net
Source: Show HN post ↗
Launched alongside, October 2024
the whole month →
bolt.new▲1,230Build and scale high-performing websites & apps using your words. Join millions and start building today.
AI · 2024 · bolt.new


Softr for Notion▲923Turn Notion databases into portals & apps with no code
Dev tools · 2024 · softr.io

One inbox for all your work discussions
Work · 2024 · generalcollaboration.com