Extension:BCmath/hi

This page is a translated version of the page Extension:BCmath and the translation is 20% complete.
मीडियाविकि एक्सटेंशन मैनुअल
OOjs UI icon advanced-invert.svg
BCmath
रिलीज़ की स्थिति: प्रयोगात्मक
PI constant.svg
कार्यान्वयन API
विवरण Provides arbitrary-precision arithmetic for Scribunto.
लेखक
  • John Erling Blad (Jebladचर्चा)
नवीनतम संस्करण 0.1.0
संगतता नीति Master maintains backward compatibility.
MediaWiki >= 1.33
डेटाबेस बदलता है नहीं
लाइसेंस GNU General Public License 2.0 or later
डाउनलोड
README, LDoc
  • $wgBCmathExtFiltering
Translate the BCmath extension

चेक उपयोग और संस्करण मैट्रिक्स.

BCmath provides arbitrary-precision arithmetic to Lua modules. With the lib from this extension it would be completely valid to do calculations on 𝜋 with 125 characters, 𝜋 ≅ 3,141 592 653 589 793 238 462 643 383 279 502 884 197 169 399 375 105 820 974 944 592 307 816 406 286 208 998 628 034 825 342 117 067 982 148 086 513 282 306 647 093 8… (Actually, the real 𝜋 is even infinitely much longer!)

The extension uses PHP BCMath Arbitrary Precision Mathematics api through use of phpseclib/bcmath_compat to access the bc programming language.

स्थापित

Expect depends on modules from the Scribunto extension.

  • अपने extensions/ फ़ोल्डर में BCmath वाली निर्देशिका में फ़ाइल डाउनलोड करें और रखें।
  • अपनी LocalSettings.php के नीचे निम्नलिखित कोड जोड़ें:
    wfLoadExtension( 'BCmath' );
    
  •   पूर्ण – इस बात की पुष्टि करने के लिए अपने विकी पर Special:Version पर नेविगेट करें कि एक्सटेंशन सफलतापूर्वक स्थापित हो गया है।

उपयोग

The workflow is to first define a BCmath instance, and then use that in ordinary equations, in chained operations, or as part of function calls. Existence of an instance in supported operations will trigger use of the special functions and methods.

-- Used for chained operations
local sum1 = mw.bcmath.new( 0.0 ):add( 42.0 )                   -- 42.000000000000000
local sum2 = mw.bcmath.new( '0' ):add( '42' )                   -- 42

-- Used in an equation
local sum3 = sum1 * sum2 + 3.14                                 -- 1767.140000000000000

-- Used in function calls
local sum4 = mw.bcmath.add( mw.bcmath.mul( sum1, sum2 ), 3.14 ) -- 1767.140000000000000
local str1 = sum4 'sci'                                         -- 1.767140000000000000e3
local str2 = sum4( 'sci', 4 )                                   -- 1.767e3

For further help, see the generated LDoc documentation.

विकास

For recreating the Vagrant-based development environment, see BCmath: Manual/Vagrant.

वैकल्पिक

The best and perhaps only real alternative is the decNumber C-library, which implements IEEE 754r, and the ldecNumber Lua wrapper library for interfacing with decNumber. These two must be used together.

The decNumber library should have a security audit before it is used, but it is probably safe. The Lua library is archived, and is hopelessly outdated with a last version (ldecNumber-21) from August 2007. There are no known MediaWiki-integration for decNumber/ldecNumber.

इसे भी देखें