Conversion.Int Metoda
Definice
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
Přetížení
| Int(Decimal) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
| Int(Double) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
| Int(Int16) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
| Int(Int32) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
| Int(Int64) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
| Int(Object) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
| Int(Single) |
Vrátí celočíselnou část čísla.Returns the integer portion of a number. |
Int(Decimal)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static System::Decimal Int(System::Decimal Number);
public static decimal Int (decimal Number);
static member Int : decimal -> decimal
Public Function Int (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
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é
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary
Platí pro
Int(Double)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static double Int(double Number);
public static double Int (double Number);
static member Int : double -> double
Public Function Int (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
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 je výkon převodu typu Double-to-Integer optimalizován, Pokud předáte hodnotu vrácenou Int metodou do kterékoli z celočíselných funkcí převodunebo pokud hodnota Double vrácená funkcí Int je automaticky převedena na celé číslo s možností stricted nastavenou na hodnotu OFF.Starting with Visual Basic 15.8, the performance of Double-to-integer conversion is optimized if you pass the value returned by the Int method to the any of the integral conversion functions, or if the Double value returned by Int 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 dbl As Double = 175.7619
Dim i3 As Integer = CInt(Int(dbl)) ' Result: 175
Viz také
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary
Platí pro
Int(Int16)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static short Int(short Number);
public static short Int (short Number);
static member Int : int16 -> int16
Public Function Int (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
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é
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary
Platí pro
Int(Int32)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static int Int(int Number);
public static int Int (int Number);
static member Int : int -> int
Public Function Int (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
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é
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary
Platí pro
Int(Int64)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static long Int(long Number);
public static long Int (long Number);
static member Int : int64 -> int64
Public Function Int (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
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é
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary
Platí pro
Int(Object)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static System::Object ^ Int(System::Object ^ Number);
public static object Int (object Number);
static member Int : obj -> obj
Public Function Int (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
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 Int metodou do kterékoli z celočíselných funkcí převodunebo pokud hodnota vrácená funkcí Int 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 Int method to the any of the integral conversion functions, or if the value returned by Int 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(Int(d)) ' Result: 173
Dim s As Object = 173.7619F
Dim i2 As Integer = CInt(Int(s)) ' Result: 173
Viz také
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary
Platí pro
Int(Single)
Vrátí celočíselnou část čísla.Returns the integer portion of a number.
public:
static float Int(float Number);
public static float Int (float Number);
static member Int : single -> single
Public Function Int (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
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 Int metodou do kterékoli z celočíselných funkcí konverzenebo pokud Single hodnota vrácená funkcí Int 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 Int method to the any of the integral conversion functions, or if the Single value returned by Int 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 sng As Single = 175.7619
Dim i3 As Integer = CInt(Fix(sng)) ' Result: 175
Viz také
- ArgumentNullException
- Funkce pro převod typůType Conversion Functions
- Souhrn datových typů (Visual Basic)Data Type Summary (Visual Basic)
- Matematický souhrnMath Summary
- Matematické funkce (Visual Basic)Math Functions (Visual Basic)
- Souhrn převoduConversion Summary