![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/share/doc/gnustep-base-doc/Base/Reference/ |
Upload File : |
<?xml version="1.0"?> <!DOCTYPE gsdoc PUBLIC "-//GNUstep//DTD gsdoc 1.0.4//EN" "http://www.gnustep.org/gsdoc-1_0_4.dtd"> <gsdoc base="NSDecimalNumber" up="Base"> <head> <title>NSDecimalNumber class reference</title> <author name="Fred Kiefer"> <email address="FredKiefer@gmx.de"> FredKiefer@gmx.de </email> </author> <copy>2000 Free Software Foundation, Inc.</copy> </head> <body> <front><contents /></front> <chapter> <heading> Software documentation for the NSDecimalNumber class </heading> <class name="NSDecimalNumber" super="NSNumber" ovadd="10.0.0"> <declared>Foundation/NSDecimalNumber.h</declared> <conform>NSDecimalNumberBehaviors</conform> <desc> <p> <strong>Class</strong> that implements a number of methods for performing decimal arithmetic to arbitrary precision. The behavior in terms of rounding choices and exception handling may be customized using the <ref type="class" id="NSDecimalNumberHandler">NSDecimalNumberHandler</ref>class, and defaults to <ref type="method" id="+defaultDecimalNumberHandler" class="NSDecimalNumberHandler">[NSDecimalNumberHandler +defaultDecimalNumberHandler]</ref>.</p> <p> Equivalent functionality to the <code>NSDecimalNumber</code> class may be accessed through functions, mostly named <code>NSDecimalXXX</code>, e.g., <ref type="function" id="NSDecimalMin"> NSDecimalMin() </ref> . Both the class and the functions use a structure called <code>NSDecimal</code>. </p> <p> Note that instances of <code>NSDecimalNumber</code> are immutable. </p> </desc> <ivariable type="NSDecimal" name="data" validity="protected" ovadd="10.0.0"> <desc> <em>Description forthcoming.</em> </desc> </ivariable> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>decimalNumberWithDecimal:</sel> <arg type="NSDecimal">decimal</arg> <desc> New instance with given value. Note an NSDecimal may be created using the function <ref type="function" id="NSDecimalFromString"> NSDecimalFromString() </ref> . </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>decimalNumberWithMantissa:</sel> <arg type="unsigned long long">mantissa</arg> <sel>exponent:</sel> <arg type="short">exponent</arg> <sel>isNegative:</sel> <arg type="BOOL">isNegative</arg> <desc> New instance by component. Note that the precision of this initializer is limited. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>decimalNumberWithString:</sel> <arg type="NSString*">numericString</arg> <desc> New instance from string. Arbitrary precision is preserved, though calling one of the <code>decimalNumberBy...</code> methods will return a result constrained by the current <em><code>scale</code></em>. Number format is parsed according to current default locale. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>decimalNumberWithString:</sel> <arg type="NSString*">numericString</arg> <sel>locale:</sel> <arg type="NSDictionary*">locale</arg> <desc> New instance from string. Arbitrary precision is preserved, though calling one of the <code>decimalNumberBy...</code> methods will return a result constrained by the current <em><code>scale</code></em>. Number format is parsed according to given <var>locale</var>. </desc> </method> <method type="id<NSDecimalNumberBehaviors>" factory="yes" ovadd="10.0.0"> <sel>defaultBehavior</sel> <desc> Returns the default rounding/precision/exception handling behavior, which is same as <ref type="method" id="+defaultDecimalNumberHandler" class="NSDecimalNumberHandler">[NSDecimalNumberHandler +defaultDecimalNumberHandler]</ref> unless it has been explicitly set otherwise. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>maximumDecimalNumber</sel> <desc> Return maximum positive value that can be represented. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>minimumDecimalNumber</sel> <desc> Return minimum negative value (<em>not</em> the smallest positive value) that can be represented. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>notANumber</sel> <desc> Return a fixed value representing an NaN. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>one</sel> <desc> Return a constant object with a value of one. </desc> </method> <method type="void" factory="yes" ovadd="10.0.0"> <sel>setDefaultBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Sets the default rounding/precision/exception handling <var>behavior</var> to the given <var>behavior</var>. If this is not called, <var>behavior</var> defaults to <ref type="method" id="+defaultDecimalNumberHandler" class="NSDecimalNumberHandler">[NSDecimalNumberHandler +defaultDecimalNumberHandler]</ref>. </desc> </method> <method type="NSDecimalNumber*" factory="yes" ovadd="10.0.0"> <sel>zero</sel> <desc> Return a constant object with a value of zero. </desc> </method> <method type="NSComparisonResult" ovadd="10.0.0"> <sel>compare:</sel> <arg type="NSNumber*">decimalNumber</arg> <desc> Compares with other number, returning less, greater, or equal. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByAdding:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <desc> Adds self to <var>decimalNumber</var> and returns new result, using <ref type="method" id="+defaultBehavior"> +defaultBehavior </ref> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByAdding:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <sel>withBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Adds self to <var>decimalNumber</var> and returns new result, using given <var>behavior</var> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByDividingBy:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <desc> Divides self by <var>decimalNumber</var> and returns new result, using <ref type="method" id="+defaultBehavior"> +defaultBehavior </ref> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByDividingBy:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <sel>withBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Divides self by <var>decimalNumber</var> and returns new result, using given <var>behavior</var> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByMultiplyingBy:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <desc> Multiplies self by <var>decimalNumber</var> and returns new result, using <ref type="method" id="+defaultBehavior"> +defaultBehavior </ref> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByMultiplyingBy:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <sel>withBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Multiplies self by <var>decimalNumber</var> and returns new result, using given <var>behavior</var> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByMultiplyingByPowerOf10:</sel> <arg type="short">power</arg> <desc> Multiplies self by given <var>power</var> of 10 and returns new result, using <ref type="method" id="+defaultBehavior"> +defaultBehavior </ref> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByMultiplyingByPowerOf10:</sel> <arg type="short">power</arg> <sel>withBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Multiplies self by given <var>power</var> of 10 and returns new result, using given <var>behavior</var> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByRaisingToPower:</sel> <arg type="NSUInteger">power</arg> <desc> Raises self to given positive integer <var>power</var> and returns new result, using <ref type="method" id="+defaultBehavior"> +defaultBehavior </ref> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByRaisingToPower:</sel> <arg type="NSUInteger">power</arg> <sel>withBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Raises self to given positive integer <var>power</var> and returns new result, using given <var>behavior</var> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberByRoundingAccordingToBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Returns rounded version of underlying decimal. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberBySubtracting:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <desc> Subtracts <var>decimalNumber</var> from self and returns new result, using <ref type="method" id="+defaultBehavior"> +defaultBehavior </ref> for rounding/precision/error handling. </desc> </method> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>decimalNumberBySubtracting:</sel> <arg type="NSDecimalNumber*">decimalNumber</arg> <sel>withBehavior:</sel> <arg type="id<NSDecimalNumberBehaviors>">behavior</arg> <desc> Subtracts <var>decimalNumber</var> from self and returns new result, using given <var>behavior</var> for rounding/precision/error handling. </desc> </method> <method type="NSDecimal" ovadd="10.0.0"> <sel>decimalValue</sel> <desc> Return underlying value as an <code>NSDecimal</code> structure. </desc> </method> <method type="NSString*" ovadd="10.0.0"> <sel>descriptionWithLocale:</sel> <arg type="id">locale</arg> <desc> Returns string version of number formatted according to <var>locale</var>. </desc> </method> <method type="double" ovadd="10.0.0"> <sel>doubleValue</sel> <desc> Returns underlying value as a <code><strong>double</strong></code>, which may be an approximation if precision greater than the default of 38. </desc> </method> <method type="id" ovadd="10.0.0"> <sel>initWithDecimal:</sel> <arg type="NSDecimal">decimal</arg> <desc> Initialize with given value. Note an NSDecimal may be created using the function <ref type="function" id="NSDecimalFromString"> NSDecimalFromString() </ref> . </desc> </method> <method type="id" ovadd="10.0.0"> <sel>initWithMantissa:</sel> <arg type="unsigned long long">mantissa</arg> <sel>exponent:</sel> <arg type="short">exponent</arg> <sel>isNegative:</sel> <arg type="BOOL">flag</arg> <desc> Initialize by component. Note that the precision of this initializer is limited. </desc> </method> <method type="id" ovadd="10.0.0"> <sel>initWithString:</sel> <arg type="NSString*">numberValue</arg> <desc> Initialize from string. Arbitrary precision is preserved, though calling one of the <code>decimalNumberBy...</code> methods will return a result constrained by the current <em><code>scale</code></em>. Number format is parsed according to current default locale. </desc> </method> <method type="id" ovadd="10.0.0"> <sel>initWithString:</sel> <arg type="NSString*">numberValue</arg> <sel>locale:</sel> <arg type="NSDictionary*">locale</arg> <desc> Initialize from string. Arbitrary precision is preserved, though calling one of the <code>decimalNumberBy...</code> methods will return a result constrained by the current <em><code>scale</code></em>. Number format is parsed according to given <var>locale</var>. </desc> </method> <method type="const char*" ovadd="10.0.0"> <sel>objCType</sel> <desc> Returns the Objective-C type ( <code>@encode(...)</code> compatible) of the data contained <code>NSDecimalNumber</code>, which is by convention "d" (for <strong>double</strong>), even though this is not strictly accurate. </desc> </method> </class> </chapter> <chapter> <heading> Software documentation for the NSDecimalNumberHandler class </heading> <class name="NSDecimalNumberHandler" super="NSObject" ovadd="10.0.0"> <declared>Foundation/NSDecimalNumber.h</declared> <conform>NSDecimalNumberBehaviors</conform> <desc> A utility class adopting <ref type="protocol" id="(NSDecimalNumberBehaviors)"><NSDecimalNumberBehaviors></ref> protocol. Can be used to control <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref> rounding and exception-handling behavior, by passing an instance as an argument to any <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref> method ending with <code>...Behavior:</code>. </desc> <ivariable type="BOOL" name="_raiseOnDivideByZero" validity="protected" ovadd="10.0.0"> <desc> <em>Warning</em> the underscore at the start of the name of this instance variable indicates that, even though it is not technically <em>private</em>, it is intended for internal use within the package, and you should not use the variable in other code. </desc> </ivariable> <ivariable type="BOOL" name="_raiseOnExactness" validity="protected" ovadd="10.0.0"> <desc> <em>Warning</em> the underscore at the start of the name of this instance variable indicates that, even though it is not technically <em>private</em>, it is intended for internal use within the package, and you should not use the variable in other code. </desc> </ivariable> <ivariable type="BOOL" name="_raiseOnOverflow" validity="protected" ovadd="10.0.0"> <desc> <em>Warning</em> the underscore at the start of the name of this instance variable indicates that, even though it is not technically <em>private</em>, it is intended for internal use within the package, and you should not use the variable in other code. </desc> </ivariable> <ivariable type="BOOL" name="_raiseOnUnderflow" validity="protected" ovadd="10.0.0"> <desc> <em>Warning</em> the underscore at the start of the name of this instance variable indicates that, even though it is not technically <em>private</em>, it is intended for internal use within the package, and you should not use the variable in other code. </desc> </ivariable> <ivariable type="NSRoundingMode" name="_roundingMode" validity="protected" ovadd="10.0.0"> <desc> <em>Warning</em> the underscore at the start of the name of this instance variable indicates that, even though it is not technically <em>private</em>, it is intended for internal use within the package, and you should not use the variable in other code. </desc> </ivariable> <ivariable type="short int" name="_scale" validity="protected" ovadd="10.0.0"> <desc> <em>Warning</em> the underscore at the start of the name of this instance variable indicates that, even though it is not technically <em>private</em>, it is intended for internal use within the package, and you should not use the variable in other code. </desc> </ivariable> <method type="id" factory="yes" ovadd="10.0.0"> <sel>decimalNumberHandlerWithRoundingMode:</sel> <arg type="NSRoundingMode">roundingMode</arg> <sel>scale:</sel> <arg type="short">scale</arg> <sel>raiseOnExactness:</sel> <arg type="BOOL">raiseOnExactness</arg> <sel>raiseOnOverflow:</sel> <arg type="BOOL">raiseOnOverflow</arg> <sel>raiseOnUnderflow:</sel> <arg type="BOOL">raiseOnUnderflow</arg> <sel>raiseOnDivideByZero:</sel> <arg type="BOOL">raiseOnDivideByZero</arg> <desc> Constructor setting all behavior. (For more precise control over error handling, create your own class implementing the <ref type="protocol" id="(NSDecimalNumberBehaviors)"><NSDecimalNumberBehaviors></ref> protocol.) </desc> </method> <method type="id" factory="yes" ovadd="10.0.0"> <sel>defaultDecimalNumberHandler</sel> <desc> Provides an instance implementing the default behavior for the <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref> class. 38 decimal digits, rounded to closest return value (<code>NSRoundPlain</code>). Exceptions raised on overflow, underflow, and divide by zero. </desc> </method> <method type="id" ovadd="10.0.0"> <sel>initWithRoundingMode:</sel> <arg type="NSRoundingMode">roundingMode</arg> <sel>scale:</sel> <arg type="short">scale</arg> <sel>raiseOnExactness:</sel> <arg type="BOOL">raiseOnExactness</arg> <sel>raiseOnOverflow:</sel> <arg type="BOOL">raiseOnOverflow</arg> <sel>raiseOnUnderflow:</sel> <arg type="BOOL">raiseOnUnderflow</arg> <sel>raiseOnDivideByZero:</sel> <arg type="BOOL">raiseOnDivideByZero</arg> <desc> Initializer setting all behavior. (For more precise control over error handling, create your own class implementing the <ref type="protocol" id="(NSDecimalNumberBehaviors)"><NSDecimalNumberBehaviors></ref> protocol.) </desc> </method> </class> </chapter> <chapter> <heading> Software documentation for the NSNumber(NSDecimalNumber) category </heading> <category name="NSDecimalNumber" class="NSNumber" ovadd="10.0.0"> <declared>Foundation/NSDecimalNumber.h</declared> <desc> Interface for obtaining an NSDecimalNumber value from an ordinary NSNumber. </desc> <method type="NSDecimal" ovadd="10.0.0"> <sel>decimalValue</sel> <desc> Obtaining an NSDecimalNumber version of an ordinary NSNumber. <br /> Returns an NSDecimal representation of the number. Float and <strong>double</strong> values may not be converted exactly </desc> </method> </category> </chapter> <chapter> <heading> Software documentation for the NSDecimalNumberBehaviors protocol </heading> <protocol name="NSDecimalNumberBehaviors" ovadd="10.0.0"> <declared>Foundation/NSDecimalNumber.h</declared> <desc> This protocol encapsulates information about how an <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref> should round and process exceptions. Usually you can just create objects of the <ref type="class" id="NSDecimalNumberHandler">NSDecimalNumberHandler</ref> class, which implements this protocol, but if you don't want to use that class you can create your own implementing it. </desc> <method type="NSDecimalNumber*" ovadd="10.0.0"> <sel>exceptionDuringOperation:</sel> <arg type="SEL">method</arg> <sel>error:</sel> <arg type="NSCalculationError">error</arg> <sel>leftOperand:</sel> <arg type="NSDecimalNumber*">leftOperand</arg> <sel>rightOperand:</sel> <arg type="NSDecimalNumber*">rightOperand</arg> <desc> <p> Specifies behavior when, in the course of applying <var>method</var> to <var>leftOperand</var> and <var>rightOperand</var>, an <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref>instance encounters given <var>error</var>.</p> <p> <var>error</var> has four possible constant values: </p> <deflist> <term> <code>NSCalculationLossOfPrecision</code> </term> <desc> The number can't be represented in 38 significant digits. </desc> <term><code>NSCalculationOverflow</code></term> <desc> The number is too large to represent. </desc> <term><code>NSCalculationUnderflow</code></term> <desc> The number is too small to represent. </desc> <term> <code>NSCalculationDivideByZero</code> </term> <desc>The caller tried to divide by 0.</desc> </deflist> <p> Behavior on <var>error</var> can be one of the following: </p> <list> <item>Raise an exception.</item> <item> Return <code>nil</code>. The calling <var>method</var> will return its value as though no <var>error</var> had occurred. If <var>error</var> is <code>NSCalculationLossOfPrecision</code>, <var>method</var> will return an imprecise value, constrained to 38 significant digits. If <var>error</var> is <code>NSCalculationUnderflow</code> or <code>NSCalculationOverflow</code>, <var>method</var> will return <code>NSDecimalNumber</code> 's <code>notANumber</code>. You shouldn't return <code>nil</code> if <var>error</var> is <code>NSDivideByZero</code>. </item> <item> Correct the <var>error</var> and return a valid <code>NSDecimalNumber</code>. The calling <var>method</var> will use this as its own return value. </item> </list> </desc> </method> <method type="NSRoundingMode" ovadd="10.0.0"> <sel>roundingMode</sel> <desc> Specifies how <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref> 's <code>decimalNumberBy...</code> methods round their return values. This should be set to one of the following constants: <deflist> <term><code>NSRoundDown</code></term> <desc>Always round down.</desc> <term><code>NSRoundUp</code></term> <desc>Always round up.</desc> <term><code>NSRoundPlain</code></term> <desc> Round to the closest possible return value. Halfway (e.g..5) rounds up for positive numbers, down for negative (towards larger absolute value). </desc> <term><code>NSRoundBankers</code></term> <desc> Round to the closest possible return value, but halfway (e.g..5) rounds towards possibility whose last digit is even. </desc> </deflist> </desc> </method> <method type="short" ovadd="10.0.0"> <sel>scale</sel> <desc> Specifies the precision of the values returned by <ref type="class" id="NSDecimalNumber">NSDecimalNumber</ref> 's <code>decimalNumberBy...</code> methods, in terms of the number of digits allowed after the decimal point. This can be negative, implying that the precision should be, e.g., 100's, 1000's, etc.. For unlimited precision, set to <code>NSDecimalNoScale</code>. </desc> </method> </protocol> </chapter> </body> </gsdoc>