Conversion.Fix Yöntem

Tanım

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Aşırı Yüklemeler

Fix(Decimal)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Double)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Int16)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Int32)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Int64)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Object)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Single)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

Fix(Decimal)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static System::Decimal Fix(System::Decimal Number);
public static decimal Fix (decimal Number);
static member Fix : decimal -> decimal
Public Function Fix (Number As Decimal) As Decimal

Parametreler

Number
Decimal

Gereklidir.Required. Bir dizi türü Decimal veya geçerli bir sayısal ifade.A number of type Decimal or any valid numeric expression.

Döndürülenler

Decimal

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Ayrıca bkz.

Şunlara uygulanır

Fix(Double)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static double Fix(double Number);
public static double Fix (double Number);
static member Fix : double -> double
Public Function Fix (Number As Double) As Double

Parametreler

Number
Double

Gereklidir.Required. Bir dizi türü Double veya geçerli bir sayısal ifade.A number of type Double or any valid numeric expression.

Döndürülenler

Double

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Visual Basic 15,8 ' den itibaren, Double Yöntem tarafından döndürülen değeri Fix integral dönüştürme işlevlerininherhangi birine geçirirseniz veya Double tarafından döndürülen değer Fix örtük olarak seçenek katı olarak ayarlanmış bir tamsayıya dönüştürülürse, tamsayı dönüştürme performansı en iyi duruma getirilir Off .Starting with Visual Basic 15.8, the performance of Double-to-integer conversion is optimized if you pass the value returned by the Fix method to the any of the integral conversion functions, or if the Double value returned by Fix is implicitly converted to an integer with Option Strict set to Off. Bu iyileştirme kodun çok daha hızlı bir şekilde çalışmasını sağlar ve tamsayı türlerine çok sayıda dönüştürme yapan kod için hızlı bir şekilde daha hızlı çalışır.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Aşağıdaki örnekte, bu tür iyileştirilmiş bir dönüştürme gösterilmektedir:The following example illustrates such an optimized conversion:

Dim d As Double = 173.7619
Dim i1 As Integer = CInt(Fix(d))           ' Result: 173

Ayrıca bkz.

Şunlara uygulanır

Fix(Int16)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static short Fix(short Number);
public static short Fix (short Number);
static member Fix : int16 -> int16
Public Function Fix (Number As Short) As Short

Parametreler

Number
Int16

Gereklidir.Required. Bir dizi türü Short veya geçerli bir sayısal ifade.A number of type Short or any valid numeric expression.

Döndürülenler

Int16

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Ayrıca bkz.

Şunlara uygulanır

Fix(Int32)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static int Fix(int Number);
public static int Fix (int Number);
static member Fix : int -> int
Public Function Fix (Number As Integer) As Integer

Parametreler

Number
Int32

Gereklidir.Required. Bir dizi türü Integer veya geçerli bir sayısal ifade.A number of type Integer or any valid numeric expression.

Döndürülenler

Int32

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Ayrıca bkz.

Şunlara uygulanır

Fix(Int64)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static long Fix(long Number);
public static long Fix (long Number);
static member Fix : int64 -> int64
Public Function Fix (Number As Long) As Long

Parametreler

Number
Int64

Gereklidir.Required. Bir dizi türü Long veya geçerli bir sayısal ifade.A number of type Long or any valid numeric expression.

Döndürülenler

Int64

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Ayrıca bkz.

Şunlara uygulanır

Fix(Object)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static System::Object ^ Fix(System::Object ^ Number);
public static object Fix (object Number);
static member Fix : obj -> obj
Public Function Fix (Number As Object) As Object

Parametreler

Number
Object

Gereklidir.Required. Bir dizi türü Object veya geçerli bir sayısal ifade.A number of type Object or any valid numeric expression. Numberİçeriyorsa Nothing , Nothing döndürülür.If Number contains Nothing, Nothing is returned.

Döndürülenler

Object

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Visual Basic 15,8 ' den itibaren Number bağımsız değişken, çalışma zamanı türü olan bir nesnedir, ya da Double Single yöntemi tarafından döndürülen değeri Fix integral dönüştürme işlevlerinegeçirirseniz, ya da tarafından döndürülen değer Fix katı olarak kapalı olarak ayarlandıysa, otomatik olarak bir tamsayıya dönüştürülürse, kayan noktalı tamsayı dönüştürme performansı en iyi duruma getirilir.Starting with Visual Basic 15.8, if the Number argument is an object whose runtime type is Double or Single, the performance of floating-point-to-integer conversion is optimized if you pass the value returned by the Fix method to the any of the integral conversion functions, or if the value returned by Fix is automatically converted to an integer with Option Strict set to Off. Bu iyileştirme kodun çok daha hızlı bir şekilde çalışmasını sağlar ve tamsayı türlerine çok sayıda dönüştürme yapan kod için hızlı bir şekilde daha hızlı çalışır.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Örnek:For example:

Dim d As Object = 173.7619
Dim i1 As Integer = CInt(Fix(d))           ' Result: 173
Dim s As Object = 173.7619F
Dim i2 As Integer = CInt(Fix(s))           ' Result: 173

Ayrıca bkz.

Şunlara uygulanır

Fix(Single)

Bir sayının tamsayı kısmını döndürür.Returns the integer portion of a number.

public:
 static float Fix(float Number);
public static float Fix (float Number);
static member Fix : single -> single
Public Function Fix (Number As Single) As Single

Parametreler

Number
Single

Gereklidir.Required. Bir dizi türü Single veya geçerli bir sayısal ifade.A number of type Single or any valid numeric expression.

Döndürülenler

Single

Bir sayının tamsayı kısmı.The integer portion of a number.

Özel durumlar

Sayı belirtilmemiş.Number is not specified.

Sayı bir sayısal tür değil.Number is not a numeric type.

Örnekler

Bu örnekte Int ve Fix işlevlerinin sayıların tamsayı kısımlarını nasıl döndürdüğü gösterilmektedir.This example illustrates how the Int and Fix functions return integer portions of numbers. Negatif sayı bağımsız değişkeni söz konusu olduğunda, işlev sayıdan Int küçük veya ona eşit olan ilk negatif tamsayıyı döndürür; işlev, sayıdan Fix büyük veya eşit olan ilk negatif tamsayıyı döndürür.In the case of a negative number argument, the Int function returns the first negative integer less than or equal to the number; the Fix function returns the first negative integer greater than or equal to the number. Aşağıdaki örnek, türünden Option Strict Off türüne örtük Dönüştürmelere Double Integer izin verilmediğinden şunları belirtmenizi gerektirir Option Strict On :The following example requires you to specify Option Strict Off because implicit conversions from type Double to type Integer are not allowed under Option Strict On:

' This code requires Option Strict Off
Dim MyNumber As Integer
MyNumber = Int(99.8)   ' Returns 99.
MyNumber = Fix(99.8)   ' Returns 99.

MyNumber = Int(-99.8)  ' Returns -100.
MyNumber = Fix(-99.8)  ' Returns -99.

MyNumber = Int(-99.2)  ' Returns -100.
MyNumber = Fix(-99.2)  ' Returns -99.

' İ kullanarak CInt diğer veri türlerini türüne açıkça dönüştürmek için işlevini kullanabilirsiniz Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Ancak, CInt sayıların kesirli kısmını kesmek yerine en yakın tamsayıya yuvarlanır.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Örnek:For example:

MyNumber = CInt(99.8)    ' Returns 100.
MyNumber = CInt(-99.8)   ' Returns -100.
MyNumber = CInt(-99.2)   ' Returns -99.

CIntBir çağrısının sonucu üzerinde, Fix Int yuvarlama yapmadan açıkça tamsayıya dönüştürme işlemi gerçekleştirmek için işlevini kullanabilirsiniz.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Örnek:For example:

MyNumber = CInt(Fix(99.8))   ' Returns 99.
MyNumber = CInt(Int(99.8))   ' Returns 99.

Hakkında daha fazla bilgi için CInt bkz. tür dönüştürme işlevleri.For more information on CInt, see Type Conversion Functions.

Açıklamalar

Ve işlevlerinin her ikisi de Int Fix kesirli kısmını kaldırır Number ve sonuç tamsayı değerini döndürür.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Ve işlevleri arasındaki fark, Int Fix Number negatifse, sıfırdan Int küçük veya buna eşit ilk negatif tamsayıyı döndürür Number , ancak değerinden Fix büyük veya buna eşit ilk negatif tamsayıyı döndürür Number .The difference between Int and Fix functions is that if Number is negative, Int returns the first negative integer less than or equal to Number, whereas Fix returns the first negative integer greater than or equal to Number. Örneğin,-8,4 ile-9 arasında bir dönüştürme Int ve-8,4 ' i Fix -8 ' e dönüştürür.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) eşdeğerdir Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Visual Basic 15,8 ' den itibaren, Single Yöntem tarafından döndürülen değeri Fix integral dönüştürme işlevlerininherhangi birine geçirirseniz veya Single tarafından döndürülen değer Fix katı olarak kapalı seçeneğini devre dışı olarak bir tamsayıya dönüştürülürse, tamsayı dönüştürme performansı en iyi duruma getirilir.Starting with Visual Basic 15.8, the performance of Single-to-integer conversion is optimized if you pass the value returned by the Fix method to the any of the integral conversion functions, or if the Single value returned by Fix is automatically converted to an integer with Option Strict set to Off. Bu iyileştirme kodun çok daha hızlı bir şekilde çalışmasını sağlar ve tamsayı türlerine çok sayıda dönüştürme yapan kod için hızlı bir şekilde daha hızlı çalışır.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Aşağıdaki örnekte, bu tür iyileştirilmiş bir dönüştürme gösterilmektedir:The following example illustrates such an optimized conversion:

Dim s As Single = 173.7619
Dim i2 As Integer = CInt(Fix(s))           ' Result: 173

Ayrıca bkz.

Şunlara uygulanır