Encoding IP addresses
-
Some years ago, I worked at the German office of a big international hospital information system manufacturer. The server was written in MUMPS (that's really a disease...), and lots of the code were developed at the US head quarters. Some day, we had problems in the communication between computers. Eventually we found out that our American colleagues stored IP addresses in two floating point numbers and then concatenated them with a ".", something like
address=float1+"."+float2
It worked fine in the US, but in Germany we use a decimal comma instead of a decimal point, and "192,168.109,47" is not a correctly formed IP address... -
Some years ago, I worked at the German office of a big international hospital information system manufacturer. The server was written in MUMPS (that's really a disease...), and lots of the code were developed at the US head quarters. Some day, we had problems in the communication between computers. Eventually we found out that our American colleagues stored IP addresses in two floating point numbers and then concatenated them with a ".", something like
address=float1+"."+float2
It worked fine in the US, but in Germany we use a decimal comma instead of a decimal point, and "192,168.109,47" is not a correctly formed IP address...Easy to fix. You can use the code we use at our company to convert floats between european/american decimals notation:
Function CAMBIADECIMAL(ByVal NUMERO As String, ByVal TIPO As Integer) As String Dim I As Integer Dim J As Integer Dim ss As String Dim ss1 As String Dim PARTE1 As String Dim PARTE2 As String Select Case TIPO Case 1 ss = NUMERO I = ss.IndexOf(".") If I > 0 Then J = ss.Length - I - 1 PARTE1 = ss.Substring(0, I) PARTE2 = ss.Substring(I + 1, J) ss1 = PARTE1 + "," + PARTE2 Return (ss1) End If Return ss Case 2 ss = NUMERO I = ss.IndexOf(",") If I > 0 Then J = ss.Length - I - 1 PARTE1 = ss.Substring(0, I) PARTE2 = ss.Substring(I + 1, J) ss1 = PARTE1 + "." + PARTE2 Return (ss1) End If Return ss End Select End Function
-
Easy to fix. You can use the code we use at our company to convert floats between european/american decimals notation:
Function CAMBIADECIMAL(ByVal NUMERO As String, ByVal TIPO As Integer) As String Dim I As Integer Dim J As Integer Dim ss As String Dim ss1 As String Dim PARTE1 As String Dim PARTE2 As String Select Case TIPO Case 1 ss = NUMERO I = ss.IndexOf(".") If I > 0 Then J = ss.Length - I - 1 PARTE1 = ss.Substring(0, I) PARTE2 = ss.Substring(I + 1, J) ss1 = PARTE1 + "," + PARTE2 Return (ss1) End If Return ss Case 2 ss = NUMERO I = ss.IndexOf(",") If I > 0 Then J = ss.Length - I - 1 PARTE1 = ss.Substring(0, I) PARTE2 = ss.Substring(I + 1, J) ss1 = PARTE1 + "." + PARTE2 Return (ss1) End If Return ss End Select End Function
Here in Argentina we also use comma as floating point separator, and the correct code that always works is: a) to retrieve the current decimal separator: System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator b) to output ANY float using "." as its decimal separator [a float].ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat); c) to parse using an invariant culture, with "." as decimal separator. System.Convert.ToSingle("3.1415926", System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
-
Here in Argentina we also use comma as floating point separator, and the correct code that always works is: a) to retrieve the current decimal separator: System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator b) to output ANY float using "." as its decimal separator [a float].ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat); c) to parse using an invariant culture, with "." as decimal separator. System.Convert.ToSingle("3.1415926", System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
-
Some years ago, I worked at the German office of a big international hospital information system manufacturer. The server was written in MUMPS (that's really a disease...), and lots of the code were developed at the US head quarters. Some day, we had problems in the communication between computers. Eventually we found out that our American colleagues stored IP addresses in two floating point numbers and then concatenated them with a ".", something like
address=float1+"."+float2
It worked fine in the US, but in Germany we use a decimal comma instead of a decimal point, and "192,168.109,47" is not a correctly formed IP address...