|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Hi all,
For a project I am doing seperate from FRC, i am making a mini darpa rover. The question i have is, how do i take a deg,min,sec value (ex. 172*34'53") and convert into decimals in programming. By hand it should be 172 + (34/60) + (53/3600). But alas I cant do that so easily in EasyC. Any suggestions? ![]() |
|
#2
|
|||||
|
|||||
|
Re: Converting Data EasyC
Put this into a user code block
answer = 172 + (34/60.0) + (53/3600.0); When you do .0 it does Decimal Division instead of integer division 34/60 in integer division is 0 so you were doing 172 + 0 + 0 |
|
#3
|
|||||
|
|||||
|
Re: Converting Data EasyC
You could also save the CPU a tiny bit of computational exertion by turning minutes into seconds first, adding the seconds, then converting the result to fractional degrees when you add things up at the end.
34*60 + 53 = 2093 172 + 2093/3600.0 = 172.581 |
|
#4
|
|||
|
|||
|
Re: Converting Data EasyC
but i wont know the value to begin with. it will come to me in the form of x*y'z" but the number could be anything
|
|
#5
|
|||||
|
|||||
|
Re: Converting Data EasyC
Is that going to be given to you as 3 separate variable?? Then you can just insert those variables into the formula. answer = Variable1 + (Variable2/60.0) + (Variable3/3600.0);
If you are given a string in that exact format then you would have to use a "Tokenizer and Tokens" not sure how you would do that in C or EasyC. If you would like how to do it in C++ send me an e-mail and I will send you some sample code. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Converting EasyC Tracking Code into MpLAB | Ultima | Programming | 5 | 08-02-2007 21:38 |
| Question about default camera data table in easyC pro | itsme | Programming | 1 | 16-01-2007 13:57 |
| Kickoff easyC workshop integrated into EasyC help file | Dan Larochelle | Programming | 0 | 11-01-2006 06:12 |