#bigint — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #bigint, aggregated by home.social.
-
Fun with #JavaScript.
BigInt: 2's complement integers with arbitrary precision which, interestingly, actually works.
Why interestingly? It works even for the ~ operator to invert "all" bits, which is kind of a stretch with arbitrary precision: all those leading zero bits?🤷
But it works: 255n & ~3n = 251, the ~ inverts "all" bits of 011 to get 111...11100 with at least enough leading 1 bits as are needed to correctly mask 11111111 to 11111100. Nice.
-
Почему в БД на PostgreSQL популярен тип numeric?
Документация PostgreSQL по numeric содержит два плохо согласующихся утверждения : «especially recommended for storing monetary amounts and other quantities where exactness is required» — и сразу же: «calculations on numeric values are very slow compared to the integer types, or to the floating-point types». То есть рекомендуют для хранения денежных величин и тут же признают, что это весьма дорого. Для меня, как разработчика СУБД это сигнал к действию. Если операции с типом заметно медленнее bigint , возникает соблазн: а нельзя ли хранить денежные величины целым числом копеек и округлять по стандартному правилу? Это бы прилично сэкономило вычислительные ресурсы наших серверов баз данных, разве нет? А что, если вообще использовать double precision ?
https://habr.com/ru/articles/1070300/
#numeric #decimal #деньги #точность_вычислений #SQLстандарт #bigint #финансовые_данные #округление #типы_данных
-
A few days ago I tried to build some perls with 32 bit ints and 128 bit floats. Cue test failures. Today I tried again, and this time I read my notes from last time on how to do it, and it Just Works.
Yay past me!
(the #BigInt modules bundled with some versions of perl don't like that combination of data sizes; the solution is to ignore their test failures, install anyway, and then upgrade to the latest versions from the #CPAN)
-
🥴 Ah, yes, the age-old challenge: cramming infinite data into finite space using #JavaScript Bigints. Because who doesn't love turning their codebase into a monument of inefficiency just to realize, "Oh wait, maybe this wasn't such a genius move after all?" 🤦♂️
https://jonathan-frere.com/posts/bigints-are-cool/ #BigInt #DataManagement #CodeInefficiency #DeveloperHumor #TechChallenges #HackerNews #ngated -
[Перевод] Как хранить деньги в базах данных и почему это не так просто, как кажется
Хранение денежных сумм в базах данных и API: анализ подходов платежных систем Хранение денег — вещь только на первый взгляд простая, а на деле содержит множество подводных камней. Выбрав не тот тип данных, можно получить неточности в расчётах, возможна путаница при переводе суммы из одной валюты в другую. А если ещё и подключать внешние API, у каждого из которых своя точность для одних и тех же валют, уследить за совместимостью еще труднее. Разбираем, как решают эти проблемы Stripe, PayPal, Google Wallet и другие платежные системы. Сравниваем три основных подхода: Integer minor units, Decimal base units и String base units.
https://habr.com/ru/articles/924838/
#валюты #валюты_мира #финансовые_системы #decimal #bigint #типы_данных #float #double #хранение_данных #платежные_системы
-
Automated testing disrupted by dog.
-
Is it just me, or is supporting the full range of 8-byte integer IDs in web applications a pain in the butt?
https://www.postgresql.org/docs/15/datatype-numeric.html
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_SAFE_INTEGER
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
https://stackoverflow.com/questions/59456390/using-bigint-in-typescript
https://stackoverflow.com/questions/18755125/node-js-is-there-any-proper-way-to-parse-json-with-large-numbers-long-biginSooo much easier to handle them as strings and do type conversions in backend code
--
#JavaScript #TypeScript #PostgreSQL #numbers #BigInt -
svg8.svg — Code is numbers.
Edition of 10
(Final version)Each character of the source code is remapped to a hexadecimal digit (0-F) with an added offset over time. Each line of code will be visited once.
Project page
↓
http://ertdfgcvb.ch/+/svgRealtime version
↓
https://objkt.com/asset/hicetnunc/815103 -
I completed #Day11 of #AdventOfCode2022. It was the hardest of the #AdventOfCode problems, for now: almost 5 hours to solve!
Difficulty: #Medium.
Part 1 was easy-to-medium: code to the specs, take care of the always-mutating array lengths during the loops.
When, at part 2, numbers started overflowing, the difficulty shot up right to Medium: I had to use #BigInt. Then, even it overflowed!
(Spoiler in the reply...)