|
|
View previous topic :: View next topic |
Author |
Message |
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
I want to use c# code with ccs complier (?) |
Posted: Thu May 07, 2015 5:42 am |
|
|
hi
I want to use c# function code with ccs complier. can anybody help me for converting the code?
here is my code:
Code: |
String[]getPrayerTimes(int year, int month, int day, double latitude, double longitude, int timeZone)
{
return getDatePrayerTimes(year, month + 1, day, latitude, longitude, timeZone);
}
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19490
|
|
Posted: Thu May 07, 2015 9:21 am |
|
|
You just have to write it.
There is nothing there to actually 'convert'.
The function getDatePrayerTimes is not a C# native function, it has been written by somebody. You have to find the algorithm used, and write this.
The 'rules of thumb' used are at:
<http://www.moonsighting.com/how-we.html>
Years ago, I wrote a system (GPS/compass based), that would give you the prayer times, and an accurate direction to Mecca. The formulae then were available in text books. The full formulae are _very_ complex, and have to be adjusted for impossible results. |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Thu May 07, 2015 9:27 am |
|
|
of course getDatePrayerTimes() is not c# function.
I have to aske that,
is this structure available in ccs?
Code: | String[]getPrayerTimes(i....) |
|
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Thu May 07, 2015 9:52 am |
|
|
CCS C is C, and not C#. C has no objects. It has no garbage collection and related memory management functions. C and C# are a world apart in some ways, and almost the only thing they share is the basic syntax.
Quote: | is this structure available in ccs? |
No, its C# and there's no direct equivalent in C. That's not a failing of CCS C, its just that C doesn't have that feature.
I read the first version of your post, the one with many of the calculations. They use doubles, and from what I saw, it needed double precision. CCS C doesn't, it only has float on most PICs, which probably isn't going to be good enough.
For this sort of function Ttelmah is right, you need to go back to the algorithm and re-implement that in CCS C rather than trying to convert a C# implementation. Because of the mathematical nature of the algorithm, you'd need to do very careful and through testing to make sure it produces the required result in all cases, not just the obvious ones.
Last edited by RF_Developer on Thu May 07, 2015 10:03 am; edited 1 time in total |
|
|
zamzam23
Joined: 25 Aug 2010 Posts: 47
|
|
Posted: Thu May 07, 2015 9:56 am |
|
|
ok thank you. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|