Jump to content



Photo
- - - - -

Gridsquares (Maidenhead Lat,lon Encoding)

GridSquares maidenhead lat lon

  • Please log in to reply
3 replies to this topic

#1 Maverich40

Maverich40

    Casio Fan

  • Members
  • PipPip
  • 32 posts
  • Gender:Male
  • Location:Pennsylvania
  • Interests:Math, Programming, Astronomy, Space

  • Calculators:
    Casio fxCG500, fxCG10, fx-115ES, &c. and other brands.

Posted 19 August 2013 - 02:37 AM

I am trying to create on my 9860 GII a program that will generate the Alpha-Numeric
string associated with converting a Latitude,Longitude into an 8 character alpha-numeric
string.
It uses ceil, mod() and other functions when I write working routines in other languages
including Fortran, Pascal, Octave and C.
But I see no Ceil(ing) or Floor functions in Casio 9860.

and I am getting very strange "MA ERROR" using Mod() function when variable contains
a mixed-value. Enter integer positive or negative values, and it gets close to generating the
first 2 Letters needed.

Enter something like 42.1, -80.1 and MOD() wants to generate "MA ERROR", but I do not
understand why.

Don't know if any one has already tried to tackle this sort of routine in Casio Basic yet,
but I'd love to see how you did it if so. :- )

Thanks.
maverich40 at ya hoo dot com

#2 3298

3298

    Casio Addict

  • Members
  • PipPipPip
  • 79 posts
  • Gender:Male
  • Location:Germany

  • Calculators:
    fx-9750G Plus
    Algebra FX 2.0 (ROM 1.03,broken)
    HP 50G

Posted 19 August 2013 - 08:11 AM

They can all be built with Int (returns the integer part of the argument) and Frac (returns the fractional part of the argument). A simple Mod replacement would use Frac, but that has been subject to many rounding errors in the past, so some clever person invented a way with Int and a subtraction. The following code pieces also include conditional stuff inside parentheses; the condition evaluates to 1 or 0 and can be used like a number, so I use it to add or subtract 1 under certain circumstances.

floor(X): (note that != is supposed to be the unequal sign)
Int X-(X<0 And Frac X!=0)
ceil(X): (almost the same, it has a + in place of the - and a > in place of the <)
Int X+(X>0 And Frac X!=0)
mod(X,Y): (like it was done on calculators before 9860 with OS 2.00, which introduced the Mod command you noticed, but that command apparently accepts integer numbers only)
X-YInt (X/Y)


#3 Maverich40

Maverich40

    Casio Fan

  • Members
  • PipPip
  • 32 posts
  • Gender:Male
  • Location:Pennsylvania
  • Interests:Math, Programming, Astronomy, Space

  • Calculators:
    Casio fxCG500, fxCG10, fx-115ES, &c. and other brands.

Posted 19 August 2013 - 06:51 PM

Frankly, I am quite amazed I got this to *WORK* !!

Apparently, and frankly I am still amazed, my test data and "real data" appear to produce the
correct output from the Casio 9860GII, using LITERAL formulas for Ceil,Mod...
(weighed against my Pascal and Octave version of the same algorithm used)

You enter a Latitude and Longitude, positive or negative values accepted now,
and the Alpha - Numeric (Digit) String appears left-to-right on the top line of the display!

QUESTION:
How do people manage to produce listings of 9860 programs using the proper symbols, etc,
and post them here. I don't mind posting this routine, others can check it for errors,
or a more elegant way of doing it!

thank you *everyone* who helped make this possible by sharing your knowledge.

//Maverich40 at ya hoo dot com//

#4 3298

3298

    Casio Addict

  • Members
  • PipPipPip
  • 79 posts
  • Gender:Male
  • Location:Germany

  • Calculators:
    fx-9750G Plus
    Algebra FX 2.0 (ROM 1.03,broken)
    HP 50G

Posted 20 August 2013 - 12:12 PM

How to generate listings of programs to post them here?
Well, there are some symbols that can't be displayed here, so that's difficult. However, there are some conventions for describing special symbols, for example ->, =>. Commands with names are usually just written down letter by letter (in the calculator's memory, these commands are one or two bytes long, not more). There is a program called Casform (http://spiderpixel.c...sformindex.html) that can convert between several file formats, including g1m (for 9860 series), cat (for CFX and AFX series), cas (an old format which is mostly the same as the on-calc bytecode format) and txt/ctf (ctf means "casio text format"). The txt/ctf format is the best one for posting it in a code block, the cat format looks similar, but with a backslash before any command or special symbol name to avoid ambiguities.

For small code snippets like those I posted above, simply typing it into the computer while looking at the calc's screen might be an option as well.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users