Skip to main content
Tweeted twitter.com/StackSoftEng/status/1137600448704069632
quote formatted quoted text, other formatting improvements.
Source Link

I was reading an article from Microsoft regarding Widening Conversions and Option Strict Onan article from Microsoft regarding Widening Conversions and Option Strict On when I got to the part

"The following conversions may lose precision: 

      Integer to Single

      Long to Single or Double

      Decimal to Single or Double

  However, these conversions do not lose information or magnitude."

https://support.microsoft.com/en-us/help/311329/option-explicit-and-option-strict-in-visual-basic-net-and-in-visual-ba

The following conversions may lose precision:

  • Integer to Single
  • Long to Single or Double
  • Decimal to Single or Double

However, these conversions do not lose information or magnitude.

.. but according to another article regarding data types,

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/another article regarding data types,

Integer type can store from -2.147.483.648 a 2.147.483.647 and

Single type can store from

   1,401298E-45 to 3,4028235E+38  for positive numbers , and
   -3,4028235E + 38 to - 1,401298E-45 for negative numbers
  • Integer type can store from -2.147.483.648 to 2.147.483.647 and

  • Single type can store from

    • 1,401298E-45 to 3,4028235E+38 for positive numbers,
    • and -3,4028235E+38 to - 1,401298E-45 for negative numbers

.. so Single can store much more numbers than Integer. I couldn't understand in what situation such conversion from Integer to Single may lose precision. Could someone explain, please?

I was reading an article from Microsoft regarding Widening Conversions and Option Strict On when I got to the part

"The following conversions may lose precision: 

      Integer to Single

      Long to Single or Double

      Decimal to Single or Double

  However, these conversions do not lose information or magnitude."

https://support.microsoft.com/en-us/help/311329/option-explicit-and-option-strict-in-visual-basic-net-and-in-visual-ba

.. but according to another article regarding data types,

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/,

Integer type can store from -2.147.483.648 a 2.147.483.647 and

Single type can store from

   1,401298E-45 to 3,4028235E+38  for positive numbers , and
   -3,4028235E + 38 to - 1,401298E-45 for negative numbers

.. so Single can store much more numbers than Integer. I couldn't understand in what situation such conversion from Integer to Single may lose precision. Could someone explain, please?

I was reading an article from Microsoft regarding Widening Conversions and Option Strict On when I got to the part

The following conversions may lose precision:

  • Integer to Single
  • Long to Single or Double
  • Decimal to Single or Double

However, these conversions do not lose information or magnitude.

.. but according to another article regarding data types,

  • Integer type can store from -2.147.483.648 to 2.147.483.647 and

  • Single type can store from

    • 1,401298E-45 to 3,4028235E+38 for positive numbers,
    • and -3,4028235E+38 to - 1,401298E-45 for negative numbers

.. so Single can store much more numbers than Integer. I couldn't understand in what situation such conversion from Integer to Single may lose precision. Could someone explain, please?

tags edited, thanks removed as per https://meta.stackexchange.com/q/2950/295232
Source Link
Glorfindel
  • 3.2k
  • 6
  • 26
  • 33

I was reading an article from Microsoft regarding Widening Conversions and Option Strict On when iI got to the part

"The following conversions may lose precision: 

      Integer to Single

      Long to Single or Double

      Decimal to Single or Double

  However, these conversions do not lose information or magnitude."

https://support.microsoft.com/en-us/help/311329/option-explicit-and-option-strict-in-visual-basic-net-and-in-visual-ba

.. but according to another article regarding data types,

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/,

Integer type can store from -2.147.483.648 a 2.147.483.647 and

Single type can store from

   1,401298E-45 to 3,4028235E+38  for positive numbers , and
   -3,4028235E + 38 to - 1,401298E-45 for negative numbers

.. so Single can store much more numbers than Integer. I couldn't understand in what situation such conversion from Integer to Single may lose precision. Could someone explain, please?

Thanks in advance :)

I was reading an article from Microsoft regarding Widening Conversions and Option Strict On when i got to the part

"The following conversions may lose precision: 

      Integer to Single

      Long to Single or Double

      Decimal to Single or Double

  However, these conversions do not lose information or magnitude."

https://support.microsoft.com/en-us/help/311329/option-explicit-and-option-strict-in-visual-basic-net-and-in-visual-ba

.. but according to another article regarding data types,

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/,

Integer type can store from -2.147.483.648 a 2.147.483.647 and

Single type can store from

   1,401298E-45 to 3,4028235E+38  for positive numbers , and
   -3,4028235E + 38 to - 1,401298E-45 for negative numbers

.. so Single can store much more numbers than Integer. I couldn't understand in what situation such conversion from Integer to Single may lose precision. Could someone explain, please?

Thanks in advance :)

I was reading an article from Microsoft regarding Widening Conversions and Option Strict On when I got to the part

"The following conversions may lose precision: 

      Integer to Single

      Long to Single or Double

      Decimal to Single or Double

  However, these conversions do not lose information or magnitude."

https://support.microsoft.com/en-us/help/311329/option-explicit-and-option-strict-in-visual-basic-net-and-in-visual-ba

.. but according to another article regarding data types,

https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/data-types/,

Integer type can store from -2.147.483.648 a 2.147.483.647 and

Single type can store from

   1,401298E-45 to 3,4028235E+38  for positive numbers , and
   -3,4028235E + 38 to - 1,401298E-45 for negative numbers

.. so Single can store much more numbers than Integer. I couldn't understand in what situation such conversion from Integer to Single may lose precision. Could someone explain, please?

Became Hot Network Question
Source Link
Vinicius V
  • 387
  • 3
  • 3
Loading