Conversion.Fix Método
Definición
Devuelve la parte entera de un número.Returns the integer portion of a number.
Sobrecargas
| Fix(Decimal) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
| Fix(Double) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
| Fix(Int16) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
| Fix(Int32) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
| Fix(Int64) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
| Fix(Object) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
| Fix(Single) |
Devuelve la parte entera de un número.Returns the integer portion of a number. |
Fix(Decimal)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Decimal
Obligatorio.Required. Número de tipo Decimal o cualquier expresión numérica válida.A number of type Decimal or any valid numeric expression.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary
Se aplica a
Fix(Double)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Double
Obligatorio.Required. Número de tipo Double o cualquier expresión numérica válida.A number of type Double or any valid numeric expression.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
A partir de Visual Basic 15,8, Double se optimiza la conversión de rendimiento a entero si se pasa el valor devuelto por el Fix método a cualquiera de las funciones de conversión integralo si el Double valor devuelto por Fix se convierte implícitamente en un entero con Option Strict establecida en 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. Esta optimización permite que el código se ejecute más rápido, hasta el doble de rápido para código que realiza un gran número de conversiones a tipos enteros.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. En el ejemplo siguiente se muestra una conversión optimizada:The following example illustrates such an optimized conversion:
Dim d As Double = 173.7619
Dim i1 As Integer = CInt(Fix(d)) ' Result: 173
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary
Se aplica a
Fix(Int16)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Int16
Obligatorio.Required. Número de tipo Short o cualquier expresión numérica válida.A number of type Short or any valid numeric expression.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary
Se aplica a
Fix(Int32)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Int32
Obligatorio.Required. Número de tipo Integer o cualquier expresión numérica válida.A number of type Integer or any valid numeric expression.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary
Se aplica a
Fix(Int64)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Int64
Obligatorio.Required. Número de tipo Long o cualquier expresión numérica válida.A number of type Long or any valid numeric expression.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary
Se aplica a
Fix(Object)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Object
Obligatorio.Required. Número de tipo Object o cualquier expresión numérica válida.A number of type Object or any valid numeric expression. Si Number contiene Nothing, se devuelve Nothing.If Number contains Nothing, Nothing is returned.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
A partir de Visual Basic 15,8, si el Number argumento es un objeto cuyo tipo en tiempo de ejecución es Double o Single , se optimiza el rendimiento de la conversión de punto flotante a entero si se pasa el valor devuelto por el Fix método a cualquiera de las funciones de conversión integral, o si el valor devuelto por Fix se convierte automáticamente en un entero con Option Strict establecida en 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. Esta optimización permite que el código se ejecute más rápido, hasta el doble de rápido para código que realiza un gran número de conversiones a tipos enteros.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. Por ejemplo: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
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary
Se aplica a
Fix(Single)
Devuelve la parte entera de un número.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
Parámetros
- Number
- Single
Obligatorio.Required. Número de tipo Single o cualquier expresión numérica válida.A number of type Single or any valid numeric expression.
Devoluciones
Parte entera de un número.The integer portion of a number.
Excepciones
No se ha especificado Number.Number is not specified.
Number no es un tipo numérico.Number is not a numeric type.
Ejemplos
En este ejemplo se muestra cómo Int las Fix funciones y devuelven partes enteras de números.This example illustrates how the Int and Fix functions return integer portions of numbers. En el caso de un argumento de número negativo, la Int función devuelve el primer entero negativo menor o igual que el número; la Fix función devuelve el primer entero negativo mayor o igual que el número.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. El ejemplo siguiente requiere que se especifique Option Strict Off porque no se permiten las conversiones implícitas del tipo Double al tipo Integer en 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.
Puede usar la CInt función para convertir explícitamente otros tipos de datos al tipo Integer con Option Strict Off .You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. Sin embargo, CInt se redondea al entero más cercano en lugar de truncar la parte fraccionaria de los números.However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. Por ejemplo:For example:
MyNumber = CInt(99.8) ' Returns 100.
MyNumber = CInt(-99.8) ' Returns -100.
MyNumber = CInt(-99.2) ' Returns -99.
Puede usar la CInt función en el resultado de una llamada a Fix o Int para realizar la conversión explícita a un entero sin redondeo.You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. Por ejemplo:For example:
MyNumber = CInt(Fix(99.8)) ' Returns 99.
MyNumber = CInt(Int(99.8)) ' Returns 99.
Para obtener más información sobre CInt , vea funciones de conversión de tipos.For more information on CInt, see Type Conversion Functions.
Comentarios
Las Int funciones y Fix quitan la parte fraccionaria de Number y devuelven el valor entero resultante.Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
La diferencia entre Int Fix las funciones y es que si Number es negativo, Int devuelve el primer entero negativo menor o igual que Number , mientras que Fix devuelve el primer entero negativo mayor o igual que 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. Por ejemplo, Int convierte-8,4 a-9 y Fix convierte-8,4 a-8.For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) es equivalente a Sign(number) * Int(Abs(number)).Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
A partir de Visual Basic 15,8, Single se optimiza la conversión de rendimiento a entero si se pasa el valor devuelto por el Fix método a cualquiera de las funciones de conversión integralo si el Single valor devuelto por Fix se convierte automáticamente en un entero con Option Strict establecida en 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. Esta optimización permite que el código se ejecute más rápido, hasta el doble de rápido para código que realiza un gran número de conversiones a tipos enteros.This optimization allows code to run faster -- up to twice as fast for code that does a large number of conversions to integer types. En el ejemplo siguiente se muestra una conversión optimizada:The following example illustrates such an optimized conversion:
Dim s As Single = 173.7619
Dim i2 As Integer = CInt(Fix(s)) ' Result: 173
Consulte también
- ArgumentNullException
- Type Conversion FunctionsType Conversion Functions
- Resumen de tipos de datos (Visual Basic)Data Type Summary (Visual Basic)
- Resumen de funciones matemáticasMath Summary
- Funciones matemáticas (Visual Basic)Math Functions (Visual Basic)
- Resumen de las conversionesConversion Summary