Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to convert the following code snippet into C#, how is this possible?

C++
char south=ais_binary[89];
    temp_s=ais_binary.substr(89,27);
    bitset<27> ii(temp_s);
    if (south=='1') {ii.flip();}
    double ais_latitude=ii.to_ulong();
    ais_latitude=ais_latitude/10000/60;
    if (south=='1') {ais_latitude *= -1;}


Thanks in advance
Posted
Comments
Albert Holguin 23-Nov-11 20:53pm    
You need to have more specific questions, "do it for me" is not the right attitude.

1 solution

First of all, the code is not so good even as C++:
1) use of all those immediate constants (89, 27, '1', etc.) makes the code very hard to maintain; 2) comparison with character '1' is bad way to represent pure logic, 3) some declarations are not shown: where is ais_binary (could be an instance of some class implementing indexing), temp_s?

The lack of some declarations makes literal translation uncertain, but you only need some ideas:



Probably that's it.

—SA
 
Share this answer
 
v2
Comments
rajeevcapgeminiindia 23-Nov-11 22:52pm    
Given code is not clear, so first of all more clarify your question.
DominicZA 24-Nov-11 3:41am    
Sorry, I should have made that question more clear, its just that it was at 3am in South Africa :P

1) ais_binary is a string
2) temp_s is a part of ais_binary that is being decoded.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900