Conversion.Fix Metoda

Definice

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Přetížení

Fix(Decimal)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Double)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Int16)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Int32)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Int64)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Object)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Single)

Vrátí celočíselnou část čísla.Returns the integer portion of a number.

Fix(Decimal)

Vrátí celočíselnou část čísla.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

Parametry

Number
Decimal

Povinná hodnota.Required. Počet typů Decimal nebo libovolný platný číselný výraz.A number of type Decimal or any valid numeric expression.

Návraty

Decimal

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Viz také

Platí pro

Fix(Double)

Vrátí celočíselnou část čísla.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

Parametry

Number
Double

Povinná hodnota.Required. Počet typů Double nebo libovolný platný číselný výraz.A number of type Double or any valid numeric expression.

Návraty

Double

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Počínaje Visual Basic 15,8 Double je převod výkonu na celé číslo optimalizován, Pokud předáte hodnotu vrácenou Fix metodou do kterékoli z celočíselných funkcí konverzenebo pokud Double hodnota vrácená funkcí Fix je implicitně převedena na celé číslo s možností Strict set na 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. Tato optimalizace umožňuje, aby kód běžel rychleji – až dvakrát pro kód, který provádí velký počet převodů na celočíselné typy.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Následující příklad znázorňuje takový optimalizovaný převod:The following example illustrates such an optimized conversion:

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

Viz také

Platí pro

Fix(Int16)

Vrátí celočíselnou část čísla.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

Parametry

Number
Int16

Povinná hodnota.Required. Počet typů Short nebo libovolný platný číselný výraz.A number of type Short or any valid numeric expression.

Návraty

Int16

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Viz také

Platí pro

Fix(Int32)

Vrátí celočíselnou část čísla.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

Parametry

Number
Int32

Povinná hodnota.Required. Počet typů Integer nebo libovolný platný číselný výraz.A number of type Integer or any valid numeric expression.

Návraty

Int32

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Viz také

Platí pro

Fix(Int64)

Vrátí celočíselnou část čísla.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

Parametry

Number
Int64

Povinná hodnota.Required. Počet typů Long nebo libovolný platný číselný výraz.A number of type Long or any valid numeric expression.

Návraty

Int64

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Viz také

Platí pro

Fix(Object)

Vrátí celočíselnou část čísla.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

Parametry

Number
Object

Povinná hodnota.Required. Počet typů Object nebo libovolný platný číselný výraz.A number of type Object or any valid numeric expression. Pokud Number obsahuje Nothing , Nothing je vrácena.If Number contains Nothing, Nothing is returned.

Návraty

Object

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Počínaje Visual Basic 15,8, pokud Number je argumentem objekt, jehož typ modulu runtime je Double nebo Single , výkon konverze s plovoucí desetinnou čárkou na celé číslo je optimalizován, Pokud předáte hodnotu vrácenou Fix metodou do kterékoli z celočíselných funkcí převodunebo pokud hodnota vrácená funkcí Fix je automaticky převedena na celé číslo s možností stricted nastavenou na hodnotu OFF.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. Tato optimalizace umožňuje, aby kód běžel rychleji – až dvakrát pro kód, který provádí velký počet převodů na celočíselné typy.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Například: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

Viz také

Platí pro

Fix(Single)

Vrátí celočíselnou část čísla.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

Parametry

Number
Single

Povinná hodnota.Required. Počet typů Single nebo libovolný platný číselný výraz.A number of type Single or any valid numeric expression.

Návraty

Single

Celočíselná část číslaThe integer portion of a number.

Výjimky

Není určeno číslo.Number is not specified.

Číslo není číselného typu.Number is not a numeric type.

Příklady

Tento příklad ukazuje, jak Int Fix funkce a vrací celočíselné části čísel.This example illustrates how the Int and Fix functions return integer portions of numbers. V případě záporného argumentu čísla Int funkce vrátí první záporné celé číslo, které je menší nebo rovno číslu; Fix funkce vrátí první záporné celé číslo, které je větší než nebo rovno číslu.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. Následující příklad vyžaduje, abyste určili, Option Strict Off že implicitní převody z typu Double na typ nejsou Integer povoleny v 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.

Funkci lze použít CInt k explicitnímu převodu jiných datových typů na typ Integer Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Nicméně CInt zaokrouhlí na nejbližší celé číslo místo zkracování zlomkové části čísel.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Například:For example:

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

Funkci lze použít CInt na výsledek volání Fix nebo Int k provedení explicitního převodu na celé číslo bez zaokrouhlení.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Například:For example:

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

Další informace o naleznete v CInt tématu funkce pro převod typů.For more information on CInt, see Type Conversion Functions.

Poznámky

Int Fix Funkce i odeberou zlomkovou část Number a vrátí výslednou celočíselnou hodnotu.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.

Rozdíl mezi Int funkcemi a Fix je, že pokud Number je záporné, Int vrátí první záporné celé číslo, které je menší než nebo rovno Number , zatímco Fix vrátí první záporné celé číslo, které je větší než nebo rovno 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. Například Int převede-8,4 na-9 a Fix převede-8,4 na-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.

Fix(number) je ekvivalentem Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

Počínaje Visual Basic 15,8 Single je převod výkonu na celé číslo optimalizován, Pokud předáte hodnotu vrácenou Fix metodou do kterékoli z celočíselných funkcí konverzenebo pokud Single hodnota vrácená funkcí Fix je automaticky převedena na celé číslo s možností Strict nastavenou na hodnotu OFF.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. Tato optimalizace umožňuje, aby kód běžel rychleji – až dvakrát pro kód, který provádí velký počet převodů na celočíselné typy.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Následující příklad znázorňuje takový optimalizovaný převod:The following example illustrates such an optimized conversion:

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

Viz také

Platí pro