Announcement

Collapse
No announcement yet.

Constant Floats array

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Constant Floats array

    All, I am needing to use a couple of fixed LAT/LON points. I have tried to use them in the following example

    #DATA
    float ETZLat 47.98706201, 46.58196794, 45.90339392
    float ETZLon -89.56729464, -90.41239819, -88.0929389
    #END

    I can't use BYTE or WORD since they are foat types of variables. I do not get any errors when I compile, but the values I get end up being 0.0000000 no matter what index I use.


    Any suggestions on an array of float values?

    Thanks,
    Keith

  • #2
    Hello Keith,

    You can store the float values on a data line, however
    it will be stored as a string.
    Code:
    #DATA
    byte ETZLat1 "47.98706201\0"
    byte ETZLat2 "46.58196794\0"
    byte ETZLat3 "45.90339392\0"
    
    byte ETZLon1 "-89.56729464\0"
    byte ETZLon2 "-90.41239819\0"
    byte ETZLon3 "-88.0929389\0"
    #END
    If you want to access them through their index, you can use an array to store
    the values.
    Code:
    var ETZLat[3]:= [ETZLat1,ETZLat2,ETZLat3];
    var ETZLon[3]:= [ETZLon1,ETZLon2,ETZLon3];
    You can convert them on their float value when you store them on a 2 word array.
    Code:
    var floatA[2];
    And using the 'flt_VAL' command to convert a string variable to a float variable
    Code:
    flt_VAL(floatA, ETZLat1); 
    flt_PRINT(floatA,"%.5f");
    Kindly refer to the "floating point functions" section of the Diablo16 Internal functions for more information.
    Please take note that the conversion only returns a 32-bit precision.

    I hope this helps.
    Best Regards,
    Kevin

    Comment


    • #3
      AH HA!
      Thanks John, I can work with that.
      Keith

      Comment


      • #4
        Hi Keith,
        No problem. Glad it helped!
        If you still have any questions, don't hesitate to ask

        Best Regards,
        Kevin

        Comment


        • #5
          Thanks Kevin,
          Sorry about calling you John, I saw your name as John Kevin, but... I didn't pay attention to your signature.
          With this little example help, I should finish up my >60Kbytes, 8 separate executables files project.
          Thanks again,
          Keith

          Comment


          • John Kevin
            John Kevin commented
            Editing a comment
            No problem either way is fine. Good luck with your project!
        Working...
        X