Test integerness: Difference between revisions
Content added Content deleted
Line 442: | Line 442: | ||
<lang c sharp> |
<lang c sharp> |
||
using System; |
|||
namespace Test_integerness |
namespace Test_integerness |
||
Line 497: | Line 496: | ||
else if(LINE.ToUpper().Contains("I")) |
else if(LINE.ToUpper().Contains("I")) |
||
{ |
{ |
||
// Delete letter i |
|||
LINE = LINE.ToUpper().Replace("I",""); |
LINE = LINE.ToUpper().Replace("I",""); |
||
string r = string.Empty; // real part |
|||
string i = string.Empty; // imaginary part |
|||
⚫ | |||
⚫ | |||
int s = 1; // sign offset |
|||
// Get sign |
|||
if(LINE[0]=='+' || LINE[0]=='-') |
|||
{ |
|||
r+=LINE[0].ToString(); |
|||
⚫ | |||
s--; |
|||
} |
|||
// Get real part |
|||
foreach (char element in LINE) |
|||
{ |
|||
if(element!='+' && element!='-') |
|||
r+=element.ToString(); |
|||
⚫ | |||
break; |
|||
} |
|||
// get imaginary part |
|||
i = LINE.Substring(LINE.Length-(r.Length+s)); |
|||
NUMBER = double.Parse(i); |
|||
if(NUMBER==0) |
if(NUMBER==0) |
||
NUMBER = double.Parse( |
NUMBER = double.Parse(r); |
||
else |
else |
||
NUMBER = double.NaN; |
NUMBER = double.NaN; |