Announcement

Collapse
No announcement yet.

Double trouble

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

  • Double trouble

    I peek'd a double value in VB and PB.
    They differ.

    I need a PB variable (double) compatible with VB.

    How?

    These are the results of 123.456

    VB:

    119
    190
    159
    26
    47
    221
    94
    64

    PB:
    0
    0
    0
    32
    47
    221
    94
    64

    The following example creates exactly the same problem!

    Code:
    #Compile Exe
     
    Function PbMain
     
        Dim dbl As Double
        dbl = 123.456
     
        MsgBox Str$( Dbl ) & ", " & Format$( Dbl, "#.#################" )
     
    End Function
    Note: I can not make use of currency or extended precision.

    ??


    ------------------
    [email protected]
    hellobasic

  • #2
    The numeric literal 123.456 is a single precision value. Change it to:

    dbl = 123.456#

    Bob Zale
    PowerBASIC Inc.


    ------------------

    Comment


    • #3
      To expand on that a little... most variable types are cross-compatible between PB and VB or, indeed, most other languages. A PowerBASIC SINGLE is the same as a Visual Basic SINGLE, a DOUBLE is a DOUBLE, a LONG is a LONG, and "rose is a rose is a rose"...

      If you find otherwise, first suspect the method you're using for comparison or a similar coding problem.

      ------------------
      Tom Hanlin
      PowerBASIC Staff

      Comment


      • #4
        Thanks, this works however, to provide a value this way is not that nice.

        But fort. most values will be stored in a double value anyway.
        (Not the way as in my test)


        ------------------
        [email protected]
        hellobasic

        Comment

        Working...
        X