# Conversion Fix Method Microsoft VisualBasic Returns the integer portion of a number.

 Fix(Decimal) Returns the integer portion of a number. Fix(Double) Returns the integer portion of a number. Fix(Int16) Returns the integer portion of a number. Fix(Int32) Returns the integer portion of a number. Fix(Int64) Returns the integer portion of a number. Fix(Object) Returns the integer portion of a number. Fix(Single) Returns the integer portion of a number.

## Fix(Decimal)

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 -> decimalPublic Function Fix (Number As Decimal) As Decimal

#### Returns

Decimal
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.

### Remarks

Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
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. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

## Fix(Double)

Returns the integer portion of a number.
public: static double Fix(double Number);public static double Fix (double Number);static member Fix : double -> doublePublic Function Fix (Number As Double) As Double

#### Returns

Double
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.

### Remarks

Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
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. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
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. This optimization allows code to run faster — up to twice as fast for code that does a large number of conversions to integer types. The following example illustrates such an optimized conversion:
Dim d As Double = 173.7619 Dim i1 As Integer = CInt(Fix(d)) ‘ Result: 173

## Fix(Int16)

Returns the integer portion of a number.
public: static short Fix(short Number);public static short Fix (short Number);static member Fix : int16 -> int16Public Function Fix (Number As Short) As Short

#### Returns

Int16
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.

### Remarks

Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
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. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

## Fix(Int32)

Returns the integer portion of a number.
public: static int Fix(int Number);public static int Fix (int Number);static member Fix : int -> intPublic Function Fix (Number As Integer) As Integer

#### Returns

Int32
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.

### Remarks

Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
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. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

## Fix(Int64)

Returns the integer portion of a number.
public: static long Fix(long Number);public static long Fix (long Number);static member Fix : int64 -> int64Public Function Fix (Number As Long) As Long

#### Returns

Int64
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.

### Remarks

Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
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. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) is equivalent to Sign(number) * Int(Abs(number)).

## Fix(Object)

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 -> objPublic Function Fix (Number As Object) As Object

#### Returns

Object
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.

### Remarks

Both the Int and Fix functions remove the fractional part of Number and return the resulting integer value.
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. For example, Int converts -8.4 to -9, and Fix converts -8.4 to -8.
Fix(number) is equivalent to Sign(number) * Int(Abs(number)).
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. This optimization allows code to run faster — up to twice as fast for code that does a large number of conversions to integer types. 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

Returns the integer portion of a number.
public: static float Fix(float Number);public static float Fix (float Number);static member Fix : single -> singlePublic Function Fix (Number As Single) As Single

#### Returns

Single
The integer portion of a number.

### Examples

This example illustrates how the Int and Fix functions return integer portions of numbers. 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. 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.
You can use the CInt function to explicitly convert other data types to type Integer with Option Strict Off. However, CInt rounds to the nearest integer instead of truncating the fractional part of numbers. For example:
MyNumber = CInt(99.8) ‘ Returns 100. MyNumber = CInt(-99.8) ‘ Returns -100. MyNumber = CInt(-99.2) ‘ Returns -99.
You can use the CInt function on the result of a call to Fix or Int to perform explicit conversion to integer without rounding. For example:
MyNumber = CInt(Fix(99.8)) ‘ Returns 99. MyNumber = CInt(Int(99.8)) ‘ Returns 99.