Convert.ToSingle Metoda

Definice

Převede zadanou hodnotu na číslo s plovoucí desetinou čárkou s jednoduchou přesností.

Přetížení

ToSingle(String, IFormatProvider)

Převede zadané řetězcové vyjádření čísla na ekvivalentní číslo s plovoucí desetinnou čárkou s jednoduchou přesností pomocí informací o formátování specifickém pro zadanou jazykovou verzi.

ToSingle(SByte)

Převede hodnotu zadaného 8bitového celého čísla se signoum parametrem na číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(Object, IFormatProvider)

Převede hodnotu zadaného objektu na číslo s plovoucí desetinou čárkou s jednoduchou přesností pomocí informací formátování specifické pro zadanou jazykovou verzi.

ToSingle(UInt64)

Převede hodnotu zadaného 64bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(UInt32)

Převede hodnotu zadaného 32bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(String)

Převede zadané řetězcové vyjádření čísla na ekvivalentní číslo s plovoucí desetinnou čárkou s jednoduchou přesností.

ToSingle(Single)

Vrátí zadané číslo s plovoucí desetinou čárkou s jednoduchou přesností. neprovádí se žádný skutečný převod.

ToSingle(Object)

Převede hodnotu zadaného objektu na číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(UInt16)

Převede hodnotu zadaného 16bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(Int32)

Převede hodnotu zadaného 32bitového signedéhohoch nástrojů na hodnotu 32bitového celého čísla s plovoucí desetinou čárkou.

ToSingle(Int16)

Převede hodnotu zadaného 16bitového 16bitového celého čísla se signoumhom s plovoucí desetinou čárkou.

ToSingle(Double)

Převede hodnotu zadaného čísla s plovoucí desetinou čárkou s dvojitou přesností na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(Decimal)

Převede hodnotu zadaného desetinného čísla na ekvivalentní číslo s plovoucí desetinnou čárkou s jednoduchou přesností.

ToSingle(DateTime)

Volání této metody vždy vyvolá InvalidCastException.

ToSingle(Char)

Volání této metody vždy vyvolá InvalidCastException.

ToSingle(Byte)

Převede hodnotu zadaného 8bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(Boolean)

Převede zadanou logickou hodnotu na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

ToSingle(Int64)

Převede hodnotu zadaného 64bitového celého čísla se signoumchůchchechůchch k zadání hodnoty 64bitového celého čísla se sadou se

ToSingle(String, IFormatProvider)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede zadané řetězcové vyjádření čísla na ekvivalentní číslo s plovoucí desetinnou čárkou s jednoduchou přesností pomocí informací o formátování specifickém pro zadanou jazykovou verzi.

public:
 static float ToSingle(System::String ^ value, IFormatProvider ^ provider);
public static float ToSingle (string value, IFormatProvider provider);
public static float ToSingle (string? value, IFormatProvider? provider);
static member ToSingle : string * IFormatProvider -> single
Public Shared Function ToSingle (value As String, provider As IFormatProvider) As Single

Parametry

value
String

Řetězec obsahující číslo k převedení.

provider
IFormatProvider

Objekt, který poskytuje informace o formátování specifické pro jazykovou verzi.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá číslu v value, nebo 0 (nula), pokud value je null.

Výjimky

value není číslo v platném formátu.

value představuje číslo, které je menší než Single.MinValue nebo větší než Single.MaxValue.

Příklady

Následující příklad používá IFormatProvider objekty, které představují jazykové verze en-US a fr-FR, když převádí prvky v poli číselných řetězců na Single hodnoty.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      string[] values = { "123456789", "12345.6789", "12 345,6789",
                          "123,456.789", "123 456,789", "123,456,789.0123",
                          "123 456 789,0123", "1.235e12", "1.03221e-05",
                          Double.MaxValue.ToString() };
      CultureInfo[] cultures = { new CultureInfo("en-US"),
                                 new CultureInfo("fr-FR") };

      foreach (CultureInfo culture in cultures)
      {
         Console.WriteLine("String -> Single Conversion Using the {0} Culture",
                           culture.Name);
         foreach (string value in values)
         {
            Console.Write("{0,22}  ->  ", value);
            try {
               Console.WriteLine(Convert.ToSingle(value, culture));
            }
            catch (FormatException) {
               Console.WriteLine("FormatException");
            }
            catch (OverflowException) {
               Console.WriteLine("OverflowException");
            }
         }
         Console.WriteLine();
      }
   }
}
// The example displays the following output:
//    String -> Single Conversion Using the en-US Culture
//                 123456789  ->  1.234568E+08
//                12345.6789  ->  12345.68
//               12 345,6789  ->  FormatException
//               123,456.789  ->  123456.8
//               123 456,789  ->  FormatException
//          123,456,789.0123  ->  1.234568E+08
//          123 456 789,0123  ->  FormatException
//                  1.235e12  ->  1.235E+12
//               1.03221e-05  ->  1.03221E-05
//     1.79769313486232E+308  ->  Overflow
//
//    String -> Single Conversion Using the fr-FR Culture
//                 123456789  ->  1.234568E+08
//                12345.6789  ->  FormatException
//               12 345,6789  ->  12345.68
//               123,456.789  ->  FormatException
//               123 456,789  ->  123456.8
//          123,456,789.0123  ->  FormatException
//          123 456 789,0123  ->  1.234568E+08
//                  1.235e12  ->  FormatException
//               1.03221e-05  ->  FormatException
//     1.79769313486232E+308  ->  FormatException
open System
open System.Globalization

let values =
    [| "123456789"; "12345.6789"; "12 345,6789"
       "123,456.789"; "123 456,789"; "123,456,789.0123"
       "123 456 789,0123"; "1.235e12"; "1.03221e-05"
       string Double.MaxValue |]
let cultures =
    [| CultureInfo "en-US"; CultureInfo "fr-FR" |]

for culture in cultures do
    printfn $"String -> Single Conversion Using the {culture.Name} Culture"
    for value in values do
        printf $"{value,22}  ->  "
        try
            printfn $"{Convert.ToSingle(value, culture)}"
        with
        | :? FormatException ->
            printfn "FormatException"
        | :? OverflowException ->
            printfn "OverflowException"
    printfn ""
// The example displays the following output:
//    String -> Single Conversion Using the en-US Culture
//                 123456789  ->  1.234568E+08
//                12345.6789  ->  12345.68
//               12 345,6789  ->  FormatException
//               123,456.789  ->  123456.8
//               123 456,789  ->  FormatException
//          123,456,789.0123  ->  1.234568E+08
//          123 456 789,0123  ->  FormatException
//                  1.235e12  ->  1.235E+12
//               1.03221e-05  ->  1.03221E-05
//     1.79769313486232E+308  ->  Overflow
//
//    String -> Single Conversion Using the fr-FR Culture
//                 123456789  ->  1.234568E+08
//                12345.6789  ->  FormatException
//               12 345,6789  ->  12345.68
//               123,456.789  ->  FormatException
//               123 456,789  ->  123456.8
//          123,456,789.0123  ->  FormatException
//          123 456 789,0123  ->  1.234568E+08
//                  1.235e12  ->  FormatException
//               1.03221e-05  ->  FormatException
//     1.79769313486232E+308  ->  FormatException
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim values() As String = { "123456789", "12345.6789", "12 345,6789", _
                                 "123,456.789", "123 456,789", "123,456,789.0123", _
                                 "123 456 789,0123", "1.235e12", "1.03221e-05", _
                                 Double.MaxValue.ToString() }
      Dim cultures() As CultureInfo = { New CultureInfo("en-US"), _
                                        New CultureInfo("fr-FR") } 

      For Each culture As CultureInfo In cultures
         Console.WriteLine("String -> Single Conversion Using the {0} Culture", _
                           culture.Name)
         For Each value As String In values
            Console.Write("{0,22}  ->  ", value)
            Try
               Console.WriteLine(Convert.ToSingle(value, culture))
            Catch e As FormatException
               Console.WriteLine("FormatException")
            CAtch e As OverflowException
               Console.WriteLine("Overflow")
            End Try   
         Next
         Console.WriteLine()
      Next                     
   End Sub
End Module
' The example displays the following output:
'    String -> Single Conversion Using the en-US Culture
'                 123456789  ->  1.234568E+08
'                12345.6789  ->  12345.68
'               12 345,6789  ->  FormatException
'               123,456.789  ->  123456.8
'               123 456,789  ->  FormatException
'          123,456,789.0123  ->  1.234568E+08
'          123 456 789,0123  ->  FormatException
'                  1.235e12  ->  1.235E+12
'               1.03221e-05  ->  1.03221E-05
'     1.79769313486232E+308  ->  Overflow
'    
'    String -> Single Conversion Using the fr-FR Culture
'                 123456789  ->  1.234568E+08
'                12345.6789  ->  FormatException
'               12 345,6789  ->  12345.68
'               123,456.789  ->  FormatException
'               123 456,789  ->  123456.8
'          123,456,789.0123  ->  FormatException
'          123 456 789,0123  ->  1.234568E+08
'                  1.235e12  ->  FormatException
'               1.03221e-05  ->  FormatException
'     1.79769313486232E+308  ->  FormatException

Poznámky

Vrácená hodnota je výsledkem vyvolání metody v Single.Parse .value

providerIFormatProvider je instance, která získá NumberFormatInfo objekt . Objekt NumberFormatInfo poskytuje informace specifické pro jazykovou verzi formátu .value Pokud provider je null, použije se NumberFormatInfo pro aktuální jazykovou verzi.

Pokud nechcete zpracovávat výjimku v případě selhání převodu, můžete místo toho volat metodu Single.TryParse . Vrátí Boolean hodnotu, která označuje, jestli byl převod úspěšný nebo neúspěšný.

Platí pro

ToSingle(SByte)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Důležité

Toto rozhraní API neodpovídá specifikaci CLS.

Převede hodnotu zadaného 8bitového celého čísla se signoum parametrem na číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::SByte value);
[System.CLSCompliant(false)]
public static float ToSingle (sbyte value);
[<System.CLSCompliant(false)>]
static member ToSingle : sbyte -> single
Public Shared Function ToSingle (value As SByte) As Single

Parametry

value
SByte

8bitové celé číslo se znaménkem pro převod.

Návraty

8bitové celé číslo se signedýmm číslem , které je ekvivalentní číslu value.

Atributy

Příklady

Následující příklad převede každý prvek podepsaného pole bajtů na Single hodnotu.

sbyte[] numbers = { SByte.MinValue, -23, 0, 17, SByte.MaxValue };
float result;

foreach (sbyte number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the SByte value '-128' to the Single value -128.
//    Converted the SByte value '-23' to the Single value -23.
//    Converted the SByte value '0' to the Single value 0.
//    Converted the SByte value '17' to the Single value 17.
//    Converted the SByte value '127' to the Single value 127.
let numbers = [| SByte.MinValue; -23y; 0y; 17y; SByte.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the SByte value '-128' to the Single value -128.
//    Converted the SByte value '-23' to the Single value -23.
//    Converted the SByte value '0' to the Single value 0.
//    Converted the SByte value '17' to the Single value 17.
//    Converted the SByte value '127' to the Single value 127.
Dim numbers() As SByte = { SByte.MinValue, -23, 0, 17, SByte.MaxValue }
Dim result As Single

For Each number As SByte In numbers
   result = Convert.ToSingle(number)
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                        number.GetType().Name, number, _
                        result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the SByte value '-128' to the Single value -128.
'    Converted the SByte value '-23' to the Single value -23.
'    Converted the SByte value '0' to the Single value 0.
'    Converted the SByte value '17' to the Single value 17.
'    Converted the SByte value '127' to the Single value 127.

Platí pro

ToSingle(Object, IFormatProvider)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného objektu na číslo s plovoucí desetinou čárkou s jednoduchou přesností pomocí informací formátování specifické pro zadanou jazykovou verzi.

public:
 static float ToSingle(System::Object ^ value, IFormatProvider ^ provider);
public static float ToSingle (object value, IFormatProvider provider);
public static float ToSingle (object? value, IFormatProvider? provider);
static member ToSingle : obj * IFormatProvider -> single
Public Shared Function ToSingle (value As Object, provider As IFormatProvider) As Single

Parametry

value
Object

Objekt, který implementuje IConvertible rozhraní.

provider
IFormatProvider

Objekt, který poskytuje informace o formátování specifické pro jazykovou verzi.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které je ekvivalentní value, nebo nula, pokud value je null.

Výjimky

value není ve vhodném formátu.

value neimplementuje IConvertible.

value představuje číslo, které je menší než Single.MinValue nebo větší než Single.MaxValue.

Příklady

Následující příklad definuje Temperature třídu, která implementuje IConvertible rozhraní . Její implementace IConvertible.ToSingle metody vrátí vnitřní hodnotu privátní Single proměnné, která představuje teplotu.

using System;
using System.Globalization;

public class Temperature : IConvertible
{
   private float m_Temp;

   public Temperature(float temperature)
   {
      this.m_Temp = temperature;
   }

   public float Celsius
   {
      get { return this.m_Temp; }
   }

   public float Kelvin
   {
      get { return this.m_Temp + 273.15f; }
   }

   public float Fahrenheit
   {
      get { return (float) Math.Round(this.m_Temp * 9 / 5 + 32, 2); }
   }

   public override string ToString()
   {
      return m_Temp.ToString("N2") + " °C";
   }

   // IConvertible implementations.
   public TypeCode GetTypeCode()
   {
      return TypeCode.Object;
   }

   public bool ToBoolean(IFormatProvider provider)
   {
      if (m_Temp == 0)
         return false;
      else
         return true;
   }

   public byte ToByte(IFormatProvider provider)
   {
      if (m_Temp < Byte.MinValue || m_Temp > Byte.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the Byte type.",
                                                   this.m_Temp));
      else
         return Convert.ToByte(this.m_Temp);
   }

   public char ToChar(IFormatProvider provider)
   {
      throw new InvalidCastException("Temperature to Char conversion is not supported.");
   }

   public DateTime ToDateTime(IFormatProvider provider)
   {
      throw new InvalidCastException("Temperature to DateTime conversion is not supported.");
   }

   public decimal ToDecimal(IFormatProvider provider)
   {
      return Convert.ToDecimal(this.m_Temp);
   }

   public double ToDouble(IFormatProvider provider)
   {
      return Convert.ToDouble(this.m_Temp);
   }

   public short ToInt16(IFormatProvider provider)
   {
      if (this.m_Temp < Int16.MinValue || this.m_Temp > Int16.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the Int16 type.",
                                                   this.m_Temp));
      else
         return Convert.ToInt16(this.m_Temp);
   }

   public int ToInt32(IFormatProvider provider)
      {
      if (this.m_Temp < Int32.MinValue || this.m_Temp > Int32.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the Int32 type.",
                                                   this.m_Temp));
      else
         return Convert.ToInt32(this.m_Temp);
   }

   public long ToInt64(IFormatProvider provider)
   {
      if (this.m_Temp < Int64.MinValue || this.m_Temp > Int64.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the Int64 type.",
                                                   this.m_Temp));
      else
         return Convert.ToInt64(this.m_Temp);
   }

   public sbyte ToSByte(IFormatProvider provider)
   {
      if (this.m_Temp < SByte.MinValue || this.m_Temp > SByte.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the SByte type.",
                                                   this.m_Temp));
      else
         return Convert.ToSByte(this.m_Temp);
   }

   public float ToSingle(IFormatProvider provider)
   {
      return this.m_Temp;
   }

   public string ToString(IFormatProvider provider)
   {
      return m_Temp.ToString("N2", provider) + " °C";
   }

   public object ToType(Type conversionType, IFormatProvider provider)
   {
      switch (Type.GetTypeCode(conversionType))
      {
         case TypeCode.Boolean:
            return this.ToBoolean(null);
         case TypeCode.Byte:
            return this.ToByte(null);
         case TypeCode.Char:
            return this.ToChar(null);
         case TypeCode.DateTime:
            return this.ToDateTime(null);
         case TypeCode.Decimal:
            return this.ToDecimal(null);
         case TypeCode.Double:
            return this.ToDouble(null);
         case TypeCode.Int16:
            return this.ToInt16(null);
         case TypeCode.Int32:
            return this.ToInt32(null);
         case TypeCode.Int64:
            return this.ToInt64(null);
         case TypeCode.Object:
            if (typeof(Temperature).Equals(conversionType))
               return this;
            else
               throw new InvalidCastException(String.Format("Conversion to a {0} is not supported.",
                                                            conversionType.Name));
         case TypeCode.SByte:
            return this.ToSByte(null);
         case TypeCode.Single:
            return this.ToSingle(null);
         case TypeCode.String:
            return this.ToString(provider);
         case TypeCode.UInt16:
            return this.ToUInt16(null);
         case TypeCode.UInt32:
            return this.ToUInt32(null);
         case TypeCode.UInt64:
            return this.ToUInt64(null);
         default:
            throw new InvalidCastException(String.Format("Conversion to {0} is not supported.", conversionType.Name));
      }
   }

   public ushort ToUInt16(IFormatProvider provider)
   {
      if (this.m_Temp < UInt16.MinValue || this.m_Temp > UInt16.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the UInt16 type.",
                                                   this.m_Temp));
      else
         return Convert.ToUInt16(this.m_Temp);
   }

   public uint ToUInt32(IFormatProvider provider)
   {
      if (this.m_Temp < UInt32.MinValue || this.m_Temp > UInt32.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the UInt32 type.",
                                                   this.m_Temp));
      else
         return Convert.ToUInt32(this.m_Temp);
   }

   public ulong ToUInt64(IFormatProvider provider)
   {
      if (this.m_Temp < UInt64.MinValue || this.m_Temp > UInt64.MaxValue)
         throw new OverflowException(String.Format("{0} is out of range of the UInt64 type.",
                                                   this.m_Temp));
      else
         return Convert.ToUInt64(this.m_Temp);
   }
}
open System

type Temperature(temperature: float32) =
    member _.Celsius =
        temperature

    member _.Kelvin =
        temperature + 273.15f

    member _.Fahrenheit =
        MathF.Round(temperature * 9f / 5f + 32f, 2)

    override _.ToString() =
        $"{temperature:N2} °C"

    // IConvertible implementations.
    interface IConvertible with

        member _.GetTypeCode() =
            TypeCode.Object

        member _.ToBoolean(provider: IFormatProvider) =
            temperature <> 0f

        member _.ToByte(provider: IFormatProvider) =
            if temperature < float32 Byte.MinValue || temperature > float32 Byte.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the Byte type.")
            else
                Convert.ToByte temperature

        member _.ToChar(provider: IFormatProvider) =
            raise (InvalidCastException "Temperature to Char conversion is not supported.")

        member _.ToDateTime(provider: IFormatProvider) =
            raise (InvalidCastException "Temperature to DateTime conversion is not supported.")

        member _.ToDecimal(provider: IFormatProvider) =
            Convert.ToDecimal temperature

        member _.ToDouble(provider: IFormatProvider) =
            Convert.ToDouble temperature

        member _.ToInt16(provider: IFormatProvider) =
            if temperature < float32 Int16.MinValue || temperature > float32 Int16.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the Int16 type.")
            else
                Convert.ToInt16 temperature

        member _.ToInt32(provider: IFormatProvider) =
            if temperature < float32 Int32.MinValue || temperature > float32 Int32.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the Int32 type.")
            else
                Convert.ToInt32 temperature

        member _.ToInt64(provider: IFormatProvider) =
            if float32 temperature < float32 Int64.MinValue || temperature > float32 Int64.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the Int64 type.")
            else
                Convert.ToInt64 temperature

        member _.ToSByte(provider: IFormatProvider) =
            if temperature < float32 SByte.MinValue || temperature > float32 SByte.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the SByte type.")
            else
                Convert.ToSByte temperature

        member _.ToSingle(provider: IFormatProvider) =
            temperature

        override _.ToString(provider: IFormatProvider) =
            temperature.ToString("N2", provider) + " °C"

        member this.ToType(conversionType: Type, provider: IFormatProvider) =
            let this = this :> IConvertible
            match Type.GetTypeCode conversionType with
            | TypeCode.Boolean ->
                this.ToBoolean null
            | TypeCode.Byte ->
                this.ToByte null
            | TypeCode.Char ->
                this.ToChar null
            | TypeCode.DateTime ->
                this.ToDateTime null
            | TypeCode.Decimal ->
                this.ToDecimal null
            | TypeCode.Double ->
                this.ToDouble null
            | TypeCode.Int16 ->
                this.ToInt16 null
            | TypeCode.Int32 ->
                this.ToInt32 null
            | TypeCode.Int64 ->
                this.ToInt64 null
            | TypeCode.Object ->
                if typeof<Temperature>.Equals conversionType then
                    this
                else
                    raise (InvalidCastException $"Conversion to a {conversionType.Name} is not supported.")
            | TypeCode.SByte ->
                this.ToSByte null
            | TypeCode.Single ->
                this.ToSingle null
            | TypeCode.String ->
                this.ToString provider
            | TypeCode.UInt16 ->
                this.ToUInt16 null
            | TypeCode.UInt32 ->
                this.ToUInt32 null
            | TypeCode.UInt64 ->
                this.ToUInt64 null
            | _ ->
                    raise (InvalidCastException $"Conversion to {conversionType.Name} is not supported.")

        member _.ToUInt16(provider: IFormatProvider) =
            if temperature < float32 UInt16.MinValue || temperature > float32 UInt16.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the UInt16 type.")
            else
                Convert.ToUInt16 temperature

        member _.ToUInt32(provider: IFormatProvider) =
            if temperature < float32 UInt32.MinValue || temperature > float32 UInt32.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the UInt32 type.")
            else
                Convert.ToUInt32 temperature

        member _.ToUInt64(provider: IFormatProvider) =
            if temperature < float32 UInt64.MinValue || temperature > float32 UInt64.MaxValue then
                raise (OverflowException $"{temperature} is out of range of the UInt64 type.")
            else
                Convert.ToUInt64 temperature
Imports System.Globalization

Public Class Temperature : Implements IConvertible
   Private m_Temp As Single

   Public Sub New(temperature As Single)
      Me.m_Temp = temperature
   End Sub
   
   Public ReadOnly Property Celsius() As Single
      Get
         Return Me.m_Temp
      End Get   
   End Property
   
   Public ReadOnly Property Kelvin() As Single
      Get
         Return Me.m_Temp + 273.15F
      End Get
   End Property
   
   Public ReadOnly Property Fahrenheit() As Single
      Get
         Return CSng(Math.Round(Me.m_Temp * 9 / 5 + 32, 2))
      End Get      
   End Property
   
   Public Overrides Function ToString() As String
      Return m_Temp.ToString("N2") & " °C"
   End Function

   ' IConvertible implementations.
   Public Function GetTypeCode() As TypeCode _
                   Implements IConvertible.GetTypeCode
      Return TypeCode.Object
   End Function
   
   Public Function ToBoolean(provider As IFormatProvider) As Boolean _
                   Implements IConvertible.ToBoolean
      If m_Temp = 0 Then
         Return False
      Else
         Return True
      End If
   End Function 
   
   Public Function ToByte(provider As IFormatProvider) As Byte _
                   Implements IConvertible.ToByte
      If m_Temp < Byte.MinValue Or m_Temp > Byte.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the Byte type.", _ 
                                                   Me.m_Temp)) 
      Else
         Return Convert.ToByte(Me.m_Temp)
      End If       
   End Function
   
   Public Function ToChar(provider As IFormatProvider) As Char _
                   Implements IConvertible.ToChar
      Throw New InvalidCastException("Temperature to Char conversion is not supported.")
   End Function 
   
   Public Function ToDateTime(provider As IFormatProvider) As Date _
                   Implements IConvertible.ToDateTime
      Throw New InvalidCastException("Temperature to DateTime conversion is not supported.")
   End Function
   
   Public Function ToDecimal(provider As IFormatProvider) As Decimal _
                   Implements IConvertible.ToDecimal
      Return Convert.ToDecimal(Me.m_Temp)
   End Function
   
   Public Function ToDouble(provider As IFormatProvider) As Double _
                   Implements IConvertible.ToDouble
      Return Convert.ToDouble(Me.m_Temp)
   End Function   
   
   Public Function ToInt16(provider As IFormatProvider) As Int16 _
                   Implements IConvertible.ToInt16
      If Me.m_Temp < Int16.MinValue Or Me.m_Temp > Int16.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the Int16 type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToInt16(Me.m_Temp)   
      End If
   End Function
   
   Public Function ToInt32(provider As IFormatProvider) As Int32 _
                   Implements IConvertible.ToInt32
      If Me.m_Temp < Int32.MinValue Or Me.m_Temp > Int32.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the Int32 type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToInt32(Me.m_Temp)
      End If      
   End Function
   
   Public Function ToInt64(provider As IFormatProvider) As Int64 _
                   Implements IConvertible.ToInt64
      If Me.m_Temp < Int64.MinValue Or Me.m_Temp > Int64.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the Int64 type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToInt64(Me.m_Temp)
      End If      
   End Function
   
   Public Function ToSByte(provider As IFormatProvider) As SByte _
                   Implements IConvertible.ToSByte
      If Me.m_Temp < SByte.MinValue Or Me.m_Temp > SByte.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the SByte type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToSByte(Me.m_Temp)
      End If      
   End Function

   Public Function ToSingle(provider As IFormatProvider) As Single _
                   Implements IConvertible.ToSingle
      Return Me.m_Temp
   End Function

   Public Overloads Function ToString(provider As IFormatProvider) As String _
                   Implements IConvertible.ToString
      Return m_Temp.ToString("N2", provider) & " °C"
   End Function
   
   Public Function ToType(conversionType As Type, provider As IFormatProvider) As Object _
                   Implements IConvertible.ToType
      Select Case Type.GetTypeCode(conversionType)
         Case TypeCode.Boolean 
            Return Me.ToBoolean(Nothing)
         Case TypeCode.Byte
            Return Me.ToByte(Nothing)
         Case TypeCode.Char
            Return Me.ToChar(Nothing)
         Case TypeCode.DateTime
            Return Me.ToDateTime(Nothing)
         Case TypeCode.Decimal
            Return Me.ToDecimal(Nothing)
         Case TypeCode.Double
            Return Me.ToDouble(Nothing)
         Case TypeCode.Int16
            Return Me.ToInt16(Nothing)
         Case TypeCode.Int32
            Return Me.ToInt32(Nothing)
         Case TypeCode.Int64
            Return Me.ToInt64(Nothing)
         Case TypeCode.Object
            If GetType(Temperature).Equals(conversionType) Then
               Return Me
            Else
               Throw New InvalidCastException(String.Format("Conversion to a {0} is not supported.", _
                                                            conversionType.Name))
            End If 
         Case TypeCode.SByte
            Return Me.ToSByte(Nothing)
         Case TypeCode.Single
            Return Me.ToSingle(Nothing)
         Case TypeCode.String
            Return Me.ToString(provider)
         Case TypeCode.UInt16
            Return Me.ToUInt16(Nothing)
         Case TypeCode.UInt32
            Return Me.ToUInt32(Nothing)
         Case TypeCode.UInt64
            Return Me.ToUInt64(Nothing)   
         Case Else
            Throw New InvalidCastException(String.Format("Conversion to {0} is not supported.", conversionType.Name))   
      End Select
   End Function
   
   Public Function ToUInt16(provider As IFormatProvider) As UInt16 _
                   Implements IConvertible.ToUInt16
      If Me.m_Temp < UInt16.MinValue Or Me.m_Temp > UInt16.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the UInt16 type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToUInt16(Me.m_Temp)
      End If   
   End Function

   Public Function ToUInt32(provider As IFormatProvider) As UInt32 _
                   Implements IConvertible.ToUInt32
      If Me.m_Temp < UInt32.MinValue Or Me.m_Temp > UInt32.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the UInt32 type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToUInt32(Me.m_Temp)
      End If   
   End Function
   
   Public Function ToUInt64(provider As IFormatProvider) As UInt64 _
                   Implements IConvertible.ToUInt64
      If Me.m_Temp < UInt64.MinValue Or Me.m_Temp > UInt64.MaxValue Then
         Throw New OverflowException(String.Format("{0} is out of range of the UInt64 type.", _
                                                   Me.m_Temp))
      Else
         Return Convert.ToUInt64(Me.m_temp)
      End If   
   End Function
End Class

Následující příklad ukazuje, jak volání Convert.ToSingle(Object, IFormatProvider) metody zase volá IConvertible.ToSingle implementaci Temperature třídy .

public class Example
{
   public static void Main()
   {
      Temperature cold = new Temperature(-40);
      Temperature freezing = new Temperature(0);
      Temperature boiling = new Temperature(100);

      Console.WriteLine(Convert.ToInt32(cold, null));
      Console.WriteLine(Convert.ToInt32(freezing, null));
      Console.WriteLine(Convert.ToDouble(boiling, null));
   }
}
// The example dosplays the following output:
//       -40
//       0
//       100
let cold = Temperature -40f
let freezing = Temperature 0f
let boiling = Temperature 100f

printfn $"{Convert.ToInt32(cold, null)}"
printfn $"{Convert.ToInt32(freezing, null)}"
printfn $"{Convert.ToDouble(boiling, null)}"
// The example dosplays the following output:
//       -40
//       0
//       100
Module Example
   Public Sub Main()
      Dim cold As New Temperature(-40)
      Dim freezing As New Temperature(0)
      Dim boiling As New Temperature(100)
      
      Console.WriteLine(Convert.ToInt32(cold, Nothing))
      Console.WriteLine(Convert.ToInt32(freezing, Nothing))
      Console.WriteLine(Convert.ToDouble(boiling, Nothing))
   End Sub
End Module
' The example displays the following output:
'       -40
'       0
'       100

Poznámky

Vrácená hodnota je výsledkem vyvolání IConvertible.ToSingle metody základního typu .value

provider umožňuje uživateli zadat informace o převodu specifické pro jazykovou verzi obsahu nástroje value. Pokud je například value hodnota String , která představuje číslo, provider může poskytnout informace specifické pro jazykovou verzi o zápisu použitém k reprezentaci daného čísla.

Základní typy ignorují provider. Parametr však může být použit, pokud value je uživatelem definovaný typ, který implementuje IConvertible rozhraní.

Platí pro

ToSingle(UInt64)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Důležité

Toto rozhraní API neodpovídá specifikaci CLS.

Převede hodnotu zadaného 64bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::UInt64 value);
[System.CLSCompliant(false)]
public static float ToSingle (ulong value);
[<System.CLSCompliant(false)>]
static member ToSingle : uint64 -> single
Public Shared Function ToSingle (value As ULong) As Single

Parametry

value
UInt64

64bitové celé číslo bez znaménka pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Atributy

Příklady

Následující příklad převede každý prvek v poli dlouhých celých čísel bez znaménka Single na hodnotu.

ulong[] numbers = { UInt64.MinValue, 121, 12345, UInt64.MaxValue };
float result;

foreach (ulong number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the UInt64 value '0' to the Single value 0.
//    Converted the UInt64 value '121' to the Single value 121.
//    Converted the UInt64 value '12345' to the Single value 12345.
//    Converted the UInt64 value '18446744073709551615' to the Single value 1.844674E+19.
let numbers = [| UInt64.MinValue; 121uL; 12345uL; UInt64.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the UInt64 value '0' to the Single value 0.
//    Converted the UInt64 value '121' to the Single value 121.
//    Converted the UInt64 value '12345' to the Single value 12345.
//    Converted the UInt64 value '18446744073709551615' to the Single value 1.844674E+19.
Dim numbers() As ULong = { UInt64.MinValue, 121, 12345, UInt64.MaxValue }
Dim result As Single

For Each number As ULong In numbers
   result = Convert.ToSingle(number)
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                        number.GetType().Name, number, _
                        result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the UInt64 value '0' to the Single value 0.
'    Converted the UInt64 value '121' to the Single value 121.
'    Converted the UInt64 value '12345' to the Single value 12345.
'    Converted the UInt64 value '18446744073709551615' to the Single value 1.844674E+19.

Platí pro

ToSingle(UInt32)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Důležité

Toto rozhraní API neodpovídá specifikaci CLS.

Převede hodnotu zadaného 32bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::UInt32 value);
[System.CLSCompliant(false)]
public static float ToSingle (uint value);
[<System.CLSCompliant(false)>]
static member ToSingle : uint32 -> single
Public Shared Function ToSingle (value As UInteger) As Single

Parametry

value
UInt32

32bitové celé číslo bez znaménka pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Atributy

Příklady

Následující příklad převede každý prvek v poli celých čísel bez znaménka Single na hodnotu.

uint[] numbers = { UInt32.MinValue, 121, 12345, UInt32.MaxValue };
float result;

foreach (uint number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the UInt32 value '0' to the Single value 0.
//    Converted the UInt32 value '121' to the Single value 121.
//    Converted the UInt32 value '12345' to the Single value 12345.
//    Converted the UInt32 value '4294967295' to the Single value 4.294967E+09.
let numbers = [| UInt32.MinValue; 121u; 12345u; UInt32.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the UInt32 value '0' to the Single value 0.
//    Converted the UInt32 value '121' to the Single value 121.
//    Converted the UInt32 value '12345' to the Single value 12345.
//    Converted the UInt32 value '4294967295' to the Single value 4.294967E+09.
   Dim numbers() As UInteger = { UInt32.MinValue, 121, 12345, UInt32.MaxValue }
   Dim result As Single

   For Each number As UInteger In numbers
      result = Convert.ToSingle(number)
         Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                           number.GetType().Name, number, _
                           result.GetType().Name, result)
   Next
   ' The example displays the following output:
'    Converted the UInt32 value '0' to the Single value 0.
'    Converted the UInt32 value '121' to the Single value 121.
'    Converted the UInt32 value '12345' to the Single value 12345.
'    Converted the UInt32 value '4294967295' to the Single value 4.294967E+09.

Platí pro

ToSingle(String)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede zadané řetězcové vyjádření čísla na ekvivalentní číslo s plovoucí desetinnou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::String ^ value);
public static float ToSingle (string value);
public static float ToSingle (string? value);
static member ToSingle : string -> single
Public Shared Function ToSingle (value As String) As Single

Parametry

value
String

Řetězec obsahující číslo k převedení.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá číslu v value, nebo 0 (nula), pokud value je null.

Výjimky

value není číslo v platném formátu.

value představuje číslo, které je menší než Single.MinValue nebo větší než Single.MaxValue.

Příklady

Následující příklad se pokusí převést každý prvek v poli číselných řetězců na Single hodnotu.

string[] values= { "-1,035.77219", "1AFF", "1e-35", "1.63f",
                   "1,635,592,999,999,999,999,999,999", "-17.455",
                   "190.34001", "1.29e325"};
float result;

foreach (string value in values)
{
   try {
      result = Convert.ToSingle(value);
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                        value.GetType().Name, value,
                        result.GetType().Name, result);
   }
   catch (FormatException) {
      Console.WriteLine("Unable to convert '{0}' to a Single.", value);
   }
   catch (OverflowException) {
      Console.WriteLine("'{0}' is outside the range of a Single.", value);
   }
}
// The example displays the following output:
//    Converted the String value '-1,035.77219' to the Single value -1035.772.
//    Unable to convert '1AFF' to a Single.
//    Converted the String value '1e-35' to the Single value 1E-35.
//    Unable to convert '1.63f' to a Single.
//    Converted the String value '1,635,592,999,999,999,999,999,999' to the Single value 1.635593E+24.
//    Converted the String value '-17.455' to the Single value -17.455.
//    Converted the String value '190.34001' to the Single value 190.34.
//    1.29e325' is outside the range of a Single.
let values =
    [| "-1,035.77219"; "1AFF"; "1e-35"; "1.63f"; "1,635,592,999,999,999,999,999,999"
       "-17.455"; "190.34001"; "1.29e325" |]

for value in values do
    try
        let result = Convert.ToSingle value
        printfn $"Converted the {value.GetType().Name} value {value} to the {result.GetType().Name} value {result}."
    with
    | :? FormatException ->
        printfn $"Unable to convert '{value}' to a Single."
    | :? OverflowException ->
        printfn $"'{value}' is outside the range of a Single."
// The example displays the following output:
//    Converted the String value '-1,035.77219' to the Single value -1035.772.
//    Unable to convert '1AFF' to a Single.
//    Converted the String value '1e-35' to the Single value 1E-35.
//    Unable to convert '1.63f' to a Single.
//    Converted the String value '1,635,592,999,999,999,999,999,999' to the Single value 1.635593E+24.
//    Converted the String value '-17.455' to the Single value -17.455.
//    Converted the String value '190.34001' to the Single value 190.34.
//    1.29e325' is outside the range of a Single.
Dim values() As String = { "-1,035.77219", "1AFF", "1e-35", "1.63f",
                           "1,635,592,999,999,999,999,999,999", "-17.455",
                           "190.34001", "1.29e325"}
Dim result As Single

For Each value As String In values
   Try
      result = Convert.ToSingle(value)
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                        value.GetType().Name, value, _
                        result.GetType().Name, result)
   Catch e As FormatException
      Console.WriteLine("Unable to convert '{0}' to a Single.", value)
   Catch e As OverflowException
      Console.WriteLine("'{0}' is outside the range of a Single.", value)
   End Try
Next
' The example displays the following output:
'    Converted the String value '-1,035.77219' to the Single value -1035.772.
'    Unable to convert '1AFF' to a Single.
'    Converted the String value '1e-35' to the Single value 1E-35.
'    Unable to convert '1.63f' to a Single.
'    Converted the String value '1,635,592,999,999,999,999,999,999' to the Single value 1.635593E+24.
'    Converted the String value '-17.455' to the Single value -17.455.
'    Converted the String value '190.34001' to the Single value 190.34.
'    '1.29e325' is outside the range of a Single.

Poznámky

ToSingle(String) Použití metody je ekvivalentem předání value metodě Single.Parse(String) . value se interpretuje pomocí konvencí formátování aktuální jazykové verze.

Pokud nechcete zpracovávat výjimku v případě selhání převodu, můžete místo toho volat metodu Single.TryParse . Vrátí Boolean hodnotu, která označuje, jestli byl převod úspěšný nebo neúspěšný.

Platí pro

ToSingle(Single)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Vrátí zadané číslo s plovoucí desetinou čárkou s jednoduchou přesností. neprovádí se žádný skutečný převod.

public:
 static float ToSingle(float value);
public static float ToSingle (float value);
static member ToSingle : single -> single
Public Shared Function ToSingle (value As Single) As Single

Parametry

value
Single

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které se má vrátit.

Návraty

value se vrátí beze změny.

Viz také

Platí pro

ToSingle(Object)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného objektu na číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::Object ^ value);
public static float ToSingle (object value);
public static float ToSingle (object? value);
static member ToSingle : obj -> single
Public Shared Function ToSingle (value As Object) As Single

Parametry

value
Object

Objekt, který implementuje IConvertible rozhraní nebo null.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které je ekvivalentní value, nebo nula, pokud value je null.

Výjimky

value není ve vhodném formátu.

value neimplementuje IConvertible rozhraní.

-nebo-

Převod není podporován.

value představuje číslo, které je menší než Single.MinValue nebo větší než Single.MaxValue.

Příklady

Následující příklad se pokusí převést každý prvek v poli objektů na Single hodnotu.

object[] values = { true, 'a', 123, 1.764e32, "9.78", "1e-02",
                    1.67e03, "A100", "1,033.67", DateTime.Now,
                    Decimal.MaxValue };
float result;

foreach (object value in values)
{
   try {
      result = Convert.ToSingle(value);
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                        value.GetType().Name, value,
                        result.GetType().Name, result);
   }
   catch (FormatException) {
      Console.WriteLine("The {0} value {1} is not recognized as a valid Single value.",
                        value.GetType().Name, value);
   }
   catch (OverflowException) {
      Console.WriteLine("The {0} value {1} is outside the range of the Single type.",
                        value.GetType().Name, value);
   }
   catch (InvalidCastException) {
      Console.WriteLine("Conversion of the {0} value {1} to a Single is not supported.",
                        value.GetType().Name, value);
   }
}
// The example displays the following output:
//    Converted the Boolean value 'True' to the Single value 1.
//    Conversion of the Char value a to a Single is not supported.
//    Converted the Int32 value '123' to the Single value 123.
//    Converted the Double value '1.764E+32' to the Single value 1.764E+32.
//    Converted the String value '9.78' to the Single value 9.78.
//    Converted the String value '1e-02' to the Single value 0.01.
//    Converted the Double value '1670' to the Single value 1670.
//    The String value A100 is not recognized as a valid Single value.
//    Converted the String value '1,033.67' to the Single value 1033.67.
//    Conversion of the DateTime value 11/7/2008 08:02:35 AM to a Single is not supported.
//    Converted the Decimal value '79228162514264337593543950335' to the Single value 7.922816E+28.
let values: obj[] =
    [| true; 'a'; 123; 1.764e32; "9.78"; "1e-02"; 1.67e03; "A100"; "1,033.67"; DateTime.Now; Decimal.MaxValue |]

for value in values do
    try
        let result = Convert.ToSingle value            
        printfn $"Converted the {value.GetType().Name} value {value} to the {result.GetType().Name} value {result}."
    with
    | :? FormatException ->
        printfn $"The {value.GetType().Name} value {value} is not recognized as a valid Single value."
    | :? OverflowException ->
        printfn $"The {value.GetType().Name} value {value} is outside the range of the Single type."
    | :? InvalidCastException ->
        printfn $"Conversion of the {value.GetType().Name} value {value} to a Single is not supported."
// The example displays the following output:
//    Converted the Boolean value 'True' to the Single value 1.
//    Conversion of the Char value a to a Single is not supported.
//    Converted the Int32 value '123' to the Single value 123.
//    Converted the Double value '1.764E+32' to the Single value 1.764E+32.
//    Converted the String value '9.78' to the Single value 9.78.
//    Converted the String value '1e-02' to the Single value 0.01.
//    Converted the Double value '1670' to the Single value 1670.
//    The String value A100 is not recognized as a valid Single value.
//    Converted the String value '1,033.67' to the Single value 1033.67.
//    Conversion of the DateTime value 11/7/2008 08:02:35 AM to a Single is not supported.
//    Converted the Decimal value '79228162514264337593543950335' to the Single value 7.922816E+28.
Dim values() As Object = { True, "a"c, 123, 1.764e32, "9.78", "1e-02", _
                           1.67e03, "A100", "1,033.67", Date.Now, _
                           Decimal.MaxValue }
Dim result As Single

For Each value As Object In values
   Try
      result = Convert.ToSingle(value)
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                        value.GetType().Name, value, _
                        result.GetType().Name, result)

   Catch e As FormatException
      Console.WriteLine("The {0} value {1} is not recognized as a valid Single value.", _
                        value.GetType().Name, value)
   Catch e As OverflowException
      Console.WriteLine("The {0} value {1} is outside the range of the Single type.", _
                        value.GetType().Name, value)

   Catch e As InvalidCastException
      Console.WriteLine("Conversion of the {0} value {1} to a Single is not supported.", _
                        value.GetType().Name, value)
   End Try
Next
' The example displays the following output:
'    Converted the Boolean value 'True' to the Single value 1.
'    Conversion of the Char value a to a Single is not supported.
'    Converted the Int32 value '123' to the Single value 123.
'    Converted the Double value '1.764E+32' to the Single value 1.764E+32.
'    Converted the String value '9.78' to the Single value 9.78.
'    Converted the String value '1e-02' to the Single value 0.01.
'    Converted the Double value '1670' to the Single value 1670.
'    The String value A100 is not recognized as a valid Single value.
'    Converted the String value '1,033.67' to the Single value 1033.67.
'    Conversion of the DateTime value 11/7/2008 07:56:24 AM to a Single is not supported.
'    Converted the Decimal value '79228162514264337593543950335' to the Single value 7.922816E+28.

Poznámky

Vrácená hodnota je výsledkem vyvolání IConvertible.ToSingle metody základního typu .value

Platí pro

ToSingle(UInt16)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Důležité

Toto rozhraní API neodpovídá specifikaci CLS.

Převede hodnotu zadaného 16bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::UInt16 value);
[System.CLSCompliant(false)]
public static float ToSingle (ushort value);
[<System.CLSCompliant(false)>]
static member ToSingle : uint16 -> single
Public Shared Function ToSingle (value As UShort) As Single

Parametry

value
UInt16

16bitové celé číslo bez znaménka pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Atributy

Příklady

Následující příklad převede každý prvek v poli 16bitových celých čísel bez znaménka Single na hodnotu.

ushort[] numbers = { UInt16.MinValue, 121, 12345, UInt16.MaxValue };
float result;

foreach (ushort number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the UInt16 value '0' to the Single value 0.
//    Converted the UInt16 value '121' to the Single value 121.
//    Converted the UInt16 value '12345' to the Single value 12345.
//    Converted the UInt16 value '65535' to the Single value 65535.
let numbers = [| UInt16.MinValue; 121us; 12345us; UInt16.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the UInt16 value '0' to the Single value 0.
//    Converted the UInt16 value '121' to the Single value 121.
//    Converted the UInt16 value '12345' to the Single value 12345.
//    Converted the UInt16 value '65535' to the Single value 65535.
Dim numbers() As UShort = { UInt16.MinValue, 121, 12345, UInt16.MaxValue }
Dim result As Single

For Each number As UShort In numbers
   result = Convert.ToSingle(number)
      Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                        number.GetType().Name, number, _
                        result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the UInt16 value '0' to the Single value 0.
'    Converted the UInt16 value '121' to the Single value 121.
'    Converted the UInt16 value '12345' to the Single value 12345.
'    Converted the UInt16 value '65535' to the Single value 65535.

Platí pro

ToSingle(Int32)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného 32bitového signedéhohoch nástrojů na hodnotu 32bitového celého čísla s plovoucí desetinou čárkou.

public:
 static float ToSingle(int value);
public static float ToSingle (int value);
static member ToSingle : int -> single
Public Shared Function ToSingle (value As Integer) As Single

Parametry

value
Int32

32bitové celé číslo se znaménkem pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Příklady

Následující příklad převede každý prvek v celočíselném poli na Single hodnotu.

int[] numbers = { Int32.MinValue, -1000, 0, 1000, Int32.MaxValue };
float result;

foreach (int number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the Int32 value '-2147483648' to the Single value -2.147484E+09.
//    Converted the Int32 value '-1000' to the Single value -1000.
//    Converted the Int32 value '0' to the Single value 0.
//    Converted the Int32 value '1000' to the Single value 1000.
//    Converted the Int32 value '2147483647' to the Single value 2.147484E+09.
let numbers = 
    [| Int32.MinValue; -1000; 0; 1000; Int32.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the Int32 value '-2147483648' to the Single value -2.147484E+09.
//    Converted the Int32 value '-1000' to the Single value -1000.
//    Converted the Int32 value '0' to the Single value 0.
//    Converted the Int32 value '1000' to the Single value 1000.
//    Converted the Int32 value '2147483647' to the Single value 2.147484E+09.
Dim numbers() As Integer = { Int32.MinValue, -1000, 0, 1000, Int32.MaxValue }
Dim result As Single

For Each number As Integer In numbers
   result = Convert.ToSingle(number)
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                     number.GetType().Name, number, _
                     result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the Int32 value '-2147483648' to the Single value -2.147484E+09.
'    Converted the Int32 value '-1000' to the Single value -1000.
'    Converted the Int32 value '0' to the Single value 0.
'    Converted the Int32 value '1000' to the Single value 1000.
'    Converted the Int32 value '2147483647' to the Single value 2.147484E+09.

Platí pro

ToSingle(Int16)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného 16bitového 16bitového celého čísla se signoumhom s plovoucí desetinou čárkou.

public:
 static float ToSingle(short value);
public static float ToSingle (short value);
static member ToSingle : int16 -> single
Public Shared Function ToSingle (value As Short) As Single

Parametry

value
Int16

16bitové celé číslo se znaménkem pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Příklady

Následující příklad převede každý prvek v poli 16bitových celých čísel na Single hodnotu.

short[] numbers = { Int16.MinValue, -1032, 0, 192, Int16.MaxValue };
float result;

foreach (short number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the Int16 value '-32768' to the Single value -32768.
//    Converted the Int16 value '-1032' to the Single value -1032.
//    Converted the Int16 value '0' to the Single value 0.
//    Converted the Int16 value '192' to the Single value 192.
//    Converted the Int16 value '32767' to the Single value 32767.
let numbers = 
    [| Int16.MinValue; -1032s; 0s; 192s; Int16.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the Int16 value '-32768' to the Single value -32768.
//    Converted the Int16 value '-1032' to the Single value -1032.
//    Converted the Int16 value '0' to the Single value 0.
//    Converted the Int16 value '192' to the Single value 192.
//    Converted the Int16 value '32767' to the Single value 32767.
Dim numbers() As Short = { Int16.MinValue, -1032, 0, 192, Int16.MaxValue }
Dim result As Single

For Each number As Short In numbers
   result = Convert.ToSingle(number)
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                     number.GetType().Name, number, _
                     result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the Int16 value '-32768' to the Single value -32768.
'    Converted the Int16 value '-1032' to the Single value -1032.
'    Converted the Int16 value '0' to the Single value 0.
'    Converted the Int16 value '192' to the Single value 192.
'    Converted the Int16 value '32767' to the Single value 32767.

Platí pro

ToSingle(Double)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného čísla s plovoucí desetinou čárkou s dvojitou přesností na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(double value);
public static float ToSingle (double value);
static member ToSingle : double -> single
Public Shared Function ToSingle (value As Double) As Single

Parametry

value
Double

Číslo s plovoucí desetinnou čárkou a dvojitou přesností pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

value se zaokrouhlí pomocí zaokrouhlení na nejbližší. Například při zaokrouhlení na dvě desetinná místa se hodnota 2,345 změní na 2,34 a hodnota 2,355 na 2,36.

Příklady

Následující příklad převede každý prvek v poli Double hodnot na Single hodnotu.

double[] values = { Double.MinValue, -1.38e10, -1023.299, -12.98,
                    0, 9.113e-16, 103.919, 17834.191, Double.MaxValue };
float result;

foreach (double value in values)
{
   result = Convert.ToSingle(value);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     value.GetType().Name, value,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the Double value '-1.79769313486232E+308' to the Single value -Infinity.
//    Converted the Double value '-13800000000' to the Single value -1.38E+10.
//    Converted the Double value '-1023.299' to the Single value -1023.299.
//    Converted the Double value '-12.98' to the Single value -12.98.
//    Converted the Double value '0' to the Single value 0.
//   Converted the Double value '9.113E-16' to the Single value 9.113E-16.
//    Converted the Double value '103.919' to the Single value 103.919.
//    Converted the Double value '17834.191' to the Single value 17834.19.
//    Converted the Double value '1.79769313486232E+308' to the Single value Infinity.
let values = 
    [| Double.MinValue; -1.38e10; -1023.299; -12.98; 0; 9.113e-16; 103.919; 17834.191; Double.MaxValue |]

for value in values do
    let result = Convert.ToSingle value
    printfn $"Converted the {value.GetType().Name} value {value} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the Double value '-1.79769313486232E+308' to the Single value -Infinity.
//    Converted the Double value '-13800000000' to the Single value -1.38E+10.
//    Converted the Double value '-1023.299' to the Single value -1023.299.
//    Converted the Double value '-12.98' to the Single value -12.98.
//    Converted the Double value '0' to the Single value 0.
//   Converted the Double value '9.113E-16' to the Single value 9.113E-16.
//    Converted the Double value '103.919' to the Single value 103.919.
//    Converted the Double value '17834.191' to the Single value 17834.19.
//    Converted the Double value '1.79769313486232E+308' to the Single value Infinity.
Dim values() As Double = { Double.MinValue, -1.38e10, -1023.299, -12.98, _
                           0, 9.113e-16, 103.919, 17834.191, Double.MaxValue }
Dim result As Single

For Each value As Double In values
   result = Convert.ToSingle(value)
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                     value.GetType().Name, value, _
                     result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the Double value '-1.79769313486232E+308' to the Single value -Infinity.
'    Converted the Double value '-13800000000' to the Single value -1.38E+10.
'    Converted the Double value '-1023.299' to the Single value -1023.299.
'    Converted the Double value '-12.98' to the Single value -12.98.
'    Converted the Double value '0' to the Single value 0.
'    Converted the Double value '9.113E-16' to the Single value 9.113E-16.
'    Converted the Double value '103.919' to the Single value 103.919.
'    Converted the Double value '17834.191' to the Single value 17834.19.
'    Converted the Double value '1.79769313486232E+308' to the Single value Infinity.

Viz také

Platí pro

ToSingle(Decimal)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného desetinného čísla na ekvivalentní číslo s plovoucí desetinnou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::Decimal value);
public static float ToSingle (decimal value);
static member ToSingle : decimal -> single
Public Shared Function ToSingle (value As Decimal) As Single

Parametry

value
Decimal

Desítkové číslo k převodu.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

value se zaokrouhlí pomocí zaokrouhlení na nejbližší. Například při zaokrouhlení na dvě desetinná místa se hodnota 2,345 změní na 2,34 a hodnota 2,355 na 2,36.

Příklady

Následující příklad převede každý prvek v poli Decimal hodnot na Single hodnotu.

decimal[] values = { Decimal.MinValue, -1034.23m, -12m, 0m, 147m,
                            199.55m, 9214.16m, Decimal.MaxValue };
float result;

foreach (var value in values)
{
   result = Convert.ToSingle(value);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     value.GetType().Name, value,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the Decimal value '-79228162514264337593543950335' to the Single value -7.9228163E+28.
//    Converted the Decimal value '-1034.23' to the Single value -1034.23.
//    Converted the Decimal value '-12' to the Single value -12.
//    Converted the Decimal value '0' to the Single value 0.
//    Converted the Decimal value '147' to the Single value 147.
//    Converted the Decimal value '199.55' to the Single value 199.55.
//    Converted the Decimal value '9214.16' to the Single value 9214.16.
//    Converted the Decimal value '79228162514264337593543950335' to the Single value 7.9228163E+28.
let values = 
    [| Decimal.MinValue; -1034.23m; -12m; 0m; 147m; 199.55m; 9214.16m; Decimal.MaxValue |]

for value in values do
    let result = Convert.ToSingle value
    printfn $"Converted the {value.GetType().Name} value {value} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the Decimal value '-79228162514264337593543950335' to the Single value -7.9228163E+28.
//    Converted the Decimal value '-1034.23' to the Single value -1034.23.
//    Converted the Decimal value '-12' to the Single value -12.
//    Converted the Decimal value '0' to the Single value 0.
//    Converted the Decimal value '147' to the Single value 147.
//    Converted the Decimal value '199.55' to the Single value 199.55.
//    Converted the Decimal value '9214.16' to the Single value 9214.16.
//    Converted the Decimal value '79228162514264337593543950335' to the Single value 7.9228163E+28.
Dim values() As Decimal = { Decimal.MinValue, -1034.23d, -12d, 0d, 147d, _
                            199.55d, 9214.16d, Decimal.MaxValue }
Dim result As Single

For Each value As Decimal In values
   result = Convert.ToSingle(value)
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                     value.GetType().Name, value, _
                     result.GetType().Name, result)
Next
' The example displays the following output:
'    Converted the Decimal value '-79228162514264337593543950335' to the Single value -7.922816E+28.
'    Converted the Decimal value '-1034.23' to the Single value -1034.23.
'    Converted the Decimal value '-12' to the Single value -12.
'    Converted the Decimal value '0' to the Single value 0.
'    Converted the Decimal value '147' to the Single value 147.
'    Converted the Decimal value '199.55' to the Single value 199.55.
'    Converted the Decimal value '9214.16' to the Single value 9214.16.
'    Converted the Decimal value '79228162514264337593543950335' to the Single value 7.922816E+28.

Viz také

Platí pro

ToSingle(DateTime)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Volání této metody vždy vyvolá InvalidCastException.

public:
 static float ToSingle(DateTime value);
public static float ToSingle (DateTime value);
static member ToSingle : DateTime -> single
Public Shared Function ToSingle (value As DateTime) As Single

Parametry

value
DateTime

Hodnota data a času pro převod.

Návraty

Tento převod není podporován. Není vrácena žádná hodnota.

Výjimky

Tento převod není podporován.

Platí pro

ToSingle(Char)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Volání této metody vždy vyvolá InvalidCastException.

public:
 static float ToSingle(char value);
public static float ToSingle (char value);
static member ToSingle : char -> single
Public Shared Function ToSingle (value As Char) As Single

Parametry

value
Char

Znak Unicode pro převod.

Návraty

Tento převod není podporován. Není vrácena žádná hodnota.

Výjimky

Tento převod není podporován.

Viz také

Platí pro

ToSingle(Byte)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného 8bitového celého čísla bez znaménka na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(System::Byte value);
public static float ToSingle (byte value);
static member ToSingle : byte -> single
Public Shared Function ToSingle (value As Byte) As Single

Parametry

value
Byte

8bitové celé číslo bez znaménka pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Příklady

Následující příklad převede každý prvek v poli hodnot bajtů na Single hodnotu.

byte[] numbers = { Byte.MinValue, 10, 100, Byte.MaxValue };
float result;

foreach (byte number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//       Converted the Byte value 0 to the Single value 0.
//       Converted the Byte value 10 to the Single value 10.
//       Converted the Byte value 100 to the Single value 100.
//       Converted the Byte value 255 to the Single value 255.
let numbers = [| Byte.MinValue; 10uy; 100uy; Byte.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//       Converted the Byte value 0 to the Single value 0.
//       Converted the Byte value 10 to the Single value 10.
//       Converted the Byte value 100 to the Single value 100.
//       Converted the Byte value 255 to the Single value 255.
Dim numbers() As Byte = { Byte.MinValue, 10, 100, Byte.MaxValue }
Dim result As Single

For Each number As Byte In numbers
   result = Convert.ToSingle(number)
   Console.WriteLine("Converted the {0} value {1} to the {2} value {3}.", _
                     number.GetType().Name, number, _
                     result.GetType().Name, result)
Next
' The example displays the following output:
'       Converted the Byte value 0 to the Single value 0.
'       Converted the Byte value 10 to the Single value 10.
'       Converted the Byte value 100 to the Single value 100.
'       Converted the Byte value 255 to the Single value 255.

Platí pro

ToSingle(Boolean)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede zadanou logickou hodnotu na ekvivalentní číslo s plovoucí desetinou čárkou s jednoduchou přesností.

public:
 static float ToSingle(bool value);
public static float ToSingle (bool value);
static member ToSingle : bool -> single
Public Shared Function ToSingle (value As Boolean) As Single

Parametry

value
Boolean

Logická hodnota, kterou chcete převést.

Návraty

Číslo 1, pokud value je true; v opačném případě 0.

Příklady

Následující příklad převede logické hodnoty true a false na Single hodnoty.

bool[] flags = { true, false };
float result;

foreach (bool flag in flags)
{
   result = Convert.ToSingle(flag);
   Console.WriteLine("Converted {0} to {1}.", flag, result);
}
// The example displays the following output:
//       Converted True to 1.
//       Converted False to 0.
let flags = [| true; false |]

for flag in flags do
    let result = Convert.ToSingle flag
    printfn $"Converted {flag} to {result}."
// The example displays the following output:
//       Converted True to 1.
//       Converted False to 0.
Dim flags() As Boolean = { True, False }
Dim result As Single

For Each flag As Boolean In flags
   result = Convert.ToSingle(flag)
   Console.WriteLine("Converted {0} to {1}.", flag, result)
Next
' The example displays the following output:
'       Converted True to 1.
'       Converted False to 0.

Platí pro

ToSingle(Int64)

Source:
Convert.cs
Source:
Convert.cs
Source:
Convert.cs

Převede hodnotu zadaného 64bitového celého čísla se signoumchůchchechůchch k zadání hodnoty 64bitového celého čísla se sadou se

public:
 static float ToSingle(long value);
public static float ToSingle (long value);
static member ToSingle : int64 -> single
Public Shared Function ToSingle (value As Long) As Single

Parametry

value
Int64

64bitové celé číslo se znaménkem pro převod.

Návraty

Číslo s plovoucí desetinou čárkou s jednoduchou přesností, které odpovídá value.

Příklady

Následující příklad převede každý prvek v poli dlouhých celých čísel na Single hodnotu.

long[] numbers = { Int64.MinValue, -903, 0, 172, Int64.MaxValue};
float result;

foreach (long number in numbers)
{
   result = Convert.ToSingle(number);
   Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
                     number.GetType().Name, number,
                     result.GetType().Name, result);
}
// The example displays the following output:
//    Converted the Int64 value '-9223372036854775808' to the Single value -9.223372E+18.
//    Converted the Int64 value '-903' to the Single value -903.
//    Converted the Int64 value '0' to the Single value 0.
//    Converted the Int64 value '172' to the Single value 172.
//    Converted the Int64 value '9223372036854775807' to the Single value 9.223372E+18.
let numbers = 
    [| Int64.MinValue; -903; 0; 172; Int64.MaxValue |]

for number in numbers do
    let result = Convert.ToSingle number
    printfn $"Converted the {number.GetType().Name} value {number} to the {result.GetType().Name} value {result}."
// The example displays the following output:
//    Converted the Int64 value '-9223372036854775808' to the Single value -9.223372E+18.
//    Converted the Int64 value '-903' to the Single value -903.
//    Converted the Int64 value '0' to the Single value 0.
//    Converted the Int64 value '172' to the Single value 172.
//    Converted the Int64 value '9223372036854775807' to the Single value 9.223372E+18.
      Dim numbers() As Long = { Int64.MinValue, -903, 0, 172, Int64.MaxValue}
      Dim result As Single

      For Each number As Long In numbers
         result = Convert.ToSingle(number)
         Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
                           number.GetType().Name, number, _
                           result.GetType().Name, result)

      Next
      ' The example displays the following output:
Converted the Int64 value '-9223372036854775808' to the Single value -9.223372E+18.
Converted the Int64 value '-903' to the Single value -903.
Converted the Int64 value '0' to the Single value 0.
Converted the Int64 value '172' to the Single value 172.
Converted the Int64 value '9223372036854775807' to the Single value 9.223372E+18.

      '    Converted the Int64 value '-9223372036854775808' to the Single value -9.223372E+18.
      '    Converted the Int64 value '-903' to the Single value -903.
      '    Converted the Int64 value '0' to the Single value 0.
      '    Converted the Int64 value '172' to the Single value 172.
      '    Converted the Int64 value '9223372036854775807' to the Single value 9.223372E+18.

Platí pro