Hi,
Trying to convert a routine in C to B4A and get false results, believing that the code marked in red is wrongly converted. Anyone who could fix that for me?
Thanks a lot!
Robert
Trying to convert a routine in C to B4A and get false results, believing that the code marked in red is wrongly converted. Anyone who could fix that for me?
Thanks a lot!
Robert
B4X:
int get_new_uranometria_page( const double ra, const double de)
{
int zone = (int)( (90. - de) * 16. / 180. + .5);
const char zone_splits[17] = { 1, 6, 10, 12, 15, 18, 18, 20, 20,
20, 18, 18, 15, 12, 10, 6, 1 };
int rval = (int)( (24. - ra) * (double)zone_splits[zone] / 24. + .5);
rval %= zone_splits[zone];
while( zone--)
rval += zone_splits[zone];
return( rval + 1);
}
B4X:
Sub PageNewUranometria(ra As Double, de As Double) As Int
Dim zone, rval As Int
Dim zone_splits() As Int
zone = Floor(90 - de) * 16 / 180 + 0.5
zone_splits = Array As Int(1, 6, 10, 12, 15, 18, 18, 20, 20, 20, 18, 18, 15, 12, 10, 6, 1)
rval = ((24 - ra) * zone_splits(zone) / 24 + .5)
rval = rval Mod zone_splits(zone)
[COLOR="Red"] Do While rval = rval - 1
zone = zone - 1
rval = rval + zone_splits(zone)
Loop[/COLOR]
Return rval + 1
End Sub
Last edited: