Double variable (64bit float) How to access bytes 4-7?


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Junior Member SCV's Avatar
    Join Date
    Nov 2015
    Posts
    46
    Thumbs Up
    Received: 0
    Given: 2
    Total Downloaded
    545.00 MB

    0 Not allowed!

    Default Double variable (64bit float) How to access bytes 4-7?

    I receive a 64bit double float over serial into a byte array. I can build the lower 4 bytes easily using

    Code:
    DIM MyDouble as Double
    DIM n as byte
    
    MyDouble.byte0 = MyArray [n] : n = n + 1
    MyDouble.byte1 = MyArray [n] : n = n + 1
    MyDouble.byte2 = MyArray [n] : n = n + 1
    MyDouble.byte3 = MyArray [n] : n = n + 1
    but PDS doesn't recognise the modifier .byte4 - 7

    Any suggestions?

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster normnet's Avatar
    Join Date
    Jul 2004
    Posts
    2,448
    Thumbs Up
    Received: 82
    Given: 50
    Total Downloaded
    1.41 GB

    0 Not allowed!

    Default Re: Double variable (64bit float) How to access bytes 4-7?

    As a workaround have you tried shifting the bits up 8 pre each load of byte 0?

    Code:
    MyDouble.byte0 = MyArray [n] : n = n + 1
    
    MyDouble = MyDouble << 8
    MyDouble.byte0 = MyArray [n] : n = n + 1
    
    MyDouble = MyDouble << 8
    MyDouble.byte0 = MyArray [n] : n = n + 1
    
    MyDouble = MyDouble << 8
    MyDouble.byte0 = MyArray [n] : n = n + 1
    
    etc.....

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,897
    Thumbs Up
    Received: 385
    Given: 196
    Total Downloaded
    2.09 GB

    0 Not allowed!

    Default Re: Double variable (64bit float) How to access bytes 4-7?

    What version of the compiler are you using?

    I added .Byte4 to .Byte7 and .Word2 and .Word3 for Double variables quite a few updates ago. For example:
    Code:
        Dim MyArray[10] As Byte
        Dim MyDouble As Double
        Dim bIndex As Byte
        
        MyDouble.Byte0 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte1 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte2 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte3 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte4 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte5 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte6 = MyArray[bIndex] : Inc bIndex
        MyDouble.Byte7 = MyArray[bIndex] : Inc bIndex
    or
    Code:
        Dim MyArray[10] As Word
        Dim MyDouble As Double
        Dim bIndex As Byte
        
        MyDouble.Word0 = MyArray[bIndex] : Inc bIndex
        MyDouble.Word1 = MyArray[bIndex] : Inc bIndex
        MyDouble.Word2 = MyArray[bIndex] : Inc bIndex
        MyDouble.Word3 = MyArray[bIndex] : Inc bIndex
    The IDE needs them added to its highlighter, so they do not, yet, turn bold black in it, but I am a single person working on both compilers, and other things to try and make a living because the compilers bring no money in at all!, so sometimes things get moved further down the list of "needs doing". LOL
    Last edited by top204; 26th November 2020 at 13:24.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Junior Member SCV's Avatar
    Join Date
    Nov 2015
    Posts
    46
    Thumbs Up
    Received: 0
    Given: 2
    Total Downloaded
    545.00 MB

    0 Not allowed!

    Default Re: Double variable (64bit float) How to access bytes 4-7?

    Hi Les, I am running P24 1.0.7.7
    I assumed as it wasn't coming up in bold there was a problem, haven't got as far as compiling yet. At least I was on the right track.

    Proton is a great product and it's development is much appreciated.
    Thankyou for the prompt response.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. serious problem with 4 bytes float
    By hassawfaa in forum Proton Plus Compiler v3
    Replies: 11
    Last Post: 2nd October 2019, 20:52
  2. What does Access mean after dimensioning a variable?
    By Dompie in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 4th December 2018, 13:10
  3. Ram Variable Bytes 18F86J55
    By Dave-S in forum Proton Plus Compiler v3
    Replies: 21
    Last Post: 19th November 2017, 00:59
  4. Replies: 2
    Last Post: 4th January 2015, 16:40

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts