C# 0 The Complete Reference


PART II C h a p t e r   2 1



Download 4,07 Mb.
Pdf ko'rish
bet791/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   787   788   789   790   791   792   793   794   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART II

C h a p t e r   2 1 :  

E x p l o r i n g   t h e   S y s t e m   N a m e s p a c e    

631


using System;

class CreateDec {

  static void Main() {

    decimal d = new decimal(12345, 0, 0, false, 2);

    Console.WriteLine(d);

  }


}

The output is shown here:

123.45

In this example, the value of the 96-bit integer is 12345. Its sign is positive, and it has two 



decimal fractions.

The methods defined by 



Decimal

 are shown in Table 21-7. The fields defined by 



Decimal

are shown in Table 21-8. 



Decimal

 also defines a large number of operators and conversions 

that allow 

decimal

 values to be used in expressions with other numeric types. The rules 

governing the use of 

decimal

 in expressions and assignments are described in Chapter 3.

Method

Meaning


public static decimal Add(decimal 

v1

,

                                      decimal 



v2

)

Returns 



v1

 + 


v2.

public static decimal Ceiling(decimal 



v

)

Returns the smallest integer (represented as a 



decimal

 value) not less than 



v.

 For example, given 

1.02,

Ceiling( )



 returns 2.0. Given –1.02, 

Ceiling( )

returns –1. 

public static int Compare(decimal 



v1

,

                                     decimal 



v2

)

Compares the numerical value of 



v1

 with that of 



v2.

 Returns zero if the values are equal. Returns a 

negative value if 

v1

 is less than 



v2.

 Returns a positive 

value if 

v1

 is greater than 



v2.

public int CompareTo(object 



v

)

Compares the numerical value of the invoking object 



with that of 

v.

 Returns zero if the values are equal. 

Returns a negative value if the invoking object has a 

lower value. Returns a positive value if the invoking 

object has a greater value.

public int CompareTo(decimal 



v

)

Compares the numerical value of the invoking object 



with that of 

v.

 Returns zero if the values are equal. 

Returns a negative value if the invoking object has a 

lower value. Returns a positive value if the invoking 

object has a greater value. 

public static decimal Divide(decimal 



v1

,

                                         decimal 



v2

)

Returns 



v1

 / 


v2.

public bool Equals(decimal 



v

)

Returns true if the value of the invoking object equals 



the value of 

v.

T

ABLE



 21-7 

Methods Defi ned by 

Decimal

www.freepdf-books.com




632

 

P a r t   I I :  



E x p l o r i n g   t h e   C #   L i b r a r y

public override bool Equals(object 



v

)

Returns true if the value of the invoking object equals 



the value of 

v.

public static bool Equals(decimal 



v1

,

                                     decimal 



v2

)

Returns true if 



v1

 equals 


v2.

public static decimal Floor(decimal 



v

)

Returns the largest integer (represented as a 



decimal

value) not greater than 



v.

 For example, given 1.02, 

Floor( )

 returns 1.0. Given –1.02, 

Floor( )

 returns –2.

public static decimal

     FromOACurrency(long 



v

)

Conver ts the OLE Automation currency value in 



v

 into 


its

decimal


 equivalent and returns the result.

public static int[ ] GetBits(decimal 



v

)

Returns the binar y representation of 



v

 as an array of 

int

. The organization of this array is as described in 



the text.

public override int GetHashCode( )

Returns the hash code for the invoking object.

public TypeCode GetTypeCode( )

Returns the 

TypeCode


 enumeration value for 

Decimal


,

which is 

TypeCode.Decimal

.

public static decimal Multiply(decimal 



v1

,

                                           decimal 



v2

)

Returns 



v1

*

v2.

public static decimal Negate(decimal 

v

)

Returns –



v.

public static decimal Parse(string 



str

)

Returns the binar y equivalent of the numeric string in 



str.

 If the string does not represent a 

decimal

 value, 


an exception is thrown. 

public static decimal

     Parse(string 

str

,

             IFormatProvider 



fmtpvdr

)

Returns the binar y equivalent of the numeric string 



in

str

 using the culture-specific information provided 

by

fmtpvdr.

 If the string does not represent a 

decimal

value, an exception is thrown.

public static decimal

     Parse(string 



str

, NumberStyles 



styles

)

Returns the binar y equivalent of the numeric string 



in

str,

 using the style information provided by 



styles.

If the string does not represent a 

decimal

 value, an 

exception is thrown.

public static decimal

    Parse(string 

str

,

             NumberStyles 



styles

,

             IFormatProvider 



fmtpvdr

)

Returns the binar y equivalent of the numeric string 



in

str

 using the style information provided by 



styles

and the culture-specific format information provided 

by

fmtpvdr.

 If the string does not represent a 

decimal

value, an exception is thrown.

public static decimal

     Remainder(decimal 



v1

, decimal 



v2

)

Returns the remainder of the integer division 



v1

/

v2.

public static decimal Round(decimal 

v

)

Returns the value of 



v

 rounded to the nearest whole 

number. 

public static decimal

     Round(decimal 

v

, int 


decPlaces

)

Returns the value of 



v

 rounded to the number of 

decimal places specified by 

decPlaces,

 which must 

be between 0 and 28.

T

ABLE



 21-7 

Methods Defi ned by 

Decimal

(continued)

Method


Meaning

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   787   788   789   790   791   792   793   794   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish