zdenekdrahos/bn-php
PHP library for working with Bangla/Bengali numbers and formatting. Convert between Bengali and Latin numerals, handle digit transformations, and support localization-friendly numeric output for apps needing Bangla numeral representation.
0.1 + 0.2 ≠ 0.3) are unacceptable. Leverages PHP’s BC Math (arbitrary-precision arithmetic) under the hood, ensuring correctness.float/double types, with minimal invasiveness. Can be integrated as a custom type (e.g., via traits, value objects, or database type mappings).string/text columns in MySQL/PostgreSQL) or a Laravel accessor/mutator layer to serialize/deserialize.float fields in Eloquent models with BN type (e.g., via casts or attributes).BN operations (e.g., where('price', '>', new BN('10.5'))).BN and native types.moneyphp/money). Requires wrappers or monkey-patching.BN strings (use json_encode for serialization).BN::sum([new BN('0.1'), new BN('0.2')]) === new BN('0.3')).float/double will fail without migration. Use deprecation warnings or feature flags during transition.BN objects (e.g., __toString() or custom JSON encoders).BN values be stored/retrieved? (e.g., string columns, custom types like DECIMAL(65,30) in PostgreSQL?)--enable-bcmath)?php -m | grep bcmath). Document as a hard requirement.NUMERIC/DECIMAL) or MySQL (DECIMAL) preferred for storage; SQLite may need workarounds.BN incorrectly; use igbinary or custom serialization.BN fields as string (e.g., "price": "10.50000000000000000000").float field with BN (e.g., Order::price).BN ↔ native types.BN-aware queries (e.g., whereBN(), orderByBN()).float fields in models/migrations.money package) with BN wrappers.float usage in favor of BN via static analysis (e.g., PHPStan).NUMERIC with precision matching BN’s scale.DECIMAL(65,30) (max precision for BC Math).TEXT and cast on retrieval.BN and native types (e.g., BN::toFloat() for legacy APIs).BN usage per feature/module (e.g., config('app.use_bn_for_payments')).float and BN temporarily).Model::increment() for BN fields). Document these overrides.zdenekdrahos/bn-php to a specific version (or fork) due to lack of maintenance.assertEquals(new BN('0.3'), new BN('0.1')->add(new BN('0.2')))).BN objects may appear opaque in logs/errors. Implement __debugInfo() for better visibility."1.0" vs. "1.00000000000000000000").BN hotpaths. Optimize with caching (e.g., memoize repeated calculations).BN is used (e.g., "Avoids floating-point errors in tax calculations").BN operations are CPU-bound. Distribute workloads to avoid bottlenecks (e.g., queue delayed jobs for heavy calculations).TEXT) may increase I/O. Benchmark vs. DECIMAL in PostgreSQL.BN objects directly (use serialized strings or hashes).BN values.BN is accidentally cast to float, silently corrupt data. Use strict typing (e.g., is_string($value) ? new BN($value) : throw new \InvalidArgumentException()).float with warnings) or runtime checks (extension_loaded('bcmath')).float DB column vs. BN app code) cause silent failures. Use migrations with doctrine/dbal for schema validation.moneyphp may fail with BN. Isolate dependencies in containers or use proxies.How can I help you explore Laravel packages today?