Representing Unsigned Values Inside Basic4ppc itself

Discussion in 'Questions (Windows Mobile)' started by Louis, Nov 11, 2007.

  1. Louis

    Louis Active Member Licensed User

    Hi.
    What data types in Basic4ppc am I able to use to read and write unsigned values to and from a file? E.G. An unsigned 32-bit Integer? Are 64-bit integers equivalent, or decimals, or doubles, or single? Thanks.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    How did you save the unsigned values?
     
  3. agraham

    agraham Expert Licensed User

    There aren't types inside Basic4PPC as such as it is very weakly typed. You can think of its' variables as strings that are converted to and from numbers and booleans as and when required. Similar to the old Variant variables in Visual Basic.

    Erel told me that all arithmetic inside B4PPC is performed as Doubles. Strong data types only mean something on the perimeter of the B4PPC universe when they are converted on the way in or out of the B4PPC world.

    See the BinaryFile library for examples of when you can specify the conversion that you need. When interfacing to objects from component libraries B4PPC automatically converts those data types it is aware of - including Control data types.
     
  4. Louis

    Louis Active Member Licensed User

    Hi. I actually haven't started working on anything involving such types, however I want to port over another source code from another language to Basic4ppc for use in my program but the language uses lots of unsigned numbers for storing data to a file. So with Basic4ppc does it really matter how data is stored as long as I use the same techniques to get it back? E.G. An unsigned integer in this other language ranges from 0 to 42949672955, where as signed 32-bit Integers range from -2147483648 to +21474836477. I guess my question is can Basic4ppc handle these and what array types do I need to use to store and retrieve values like these? What's confusing is that both the decimals and doubles described in General.txt have the letter E in them and I am not sure how to interpret whether or not those types are the right ones for arrays holding huge values like the ones listed above. Thanks.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    A regular variable (which is based on 64 bit floating point) can handle these numbers without any loss.
     
  6. agraham

    agraham Expert Licensed User

    If you are not going to pass the arrays themselves to a library but are only going to read/write them from/to a file just use an ordinary array in B4PPC. If you were going to pass the array itself to a library you would need to declare the array as being of the type expected by the library as, for efficiency, B4PPC does not automatically convert entire arrays when passing them to libraries.


    Erel - for clarification. I haven't tried it but does B4PPC automatically convert individual array elements when passing them singly? e.g. array(x) of an array of Bytes being passed as an Int32 parameter to a library.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Yes. It doesn't matter where the value comes from as long as it is a single convertible value.
     
Loading...