[Gambas-user] Precision immediately lost when assigning value to type Single structure property

Kevin Fishburne kevinfishburne at ...1887...
Thu Apr 10 06:43:27 CEST 2014


I have an array (Plan) of a structure (PlanStructure) which contains 
several other structures (PlanPortalStructure, etc.):

    ' Architectural plan portal structure (server).
    Public Struct PlanPortalStructure
       PlanX As Short        ' Position in architectural plan.
       PlanY As Short        ' Position in architectural plan.
       Created As Boolean    ' If portal PWO has already been created.
       Skin As Short         ' Portal skin.
       Orientation As Single ' Portal orientation.
    End Struct

    ' Architectural plan structure (server).
    Public Struct PlanStructure
       Stage As Byte                           ' Current build stage (0
    = design, 1 = clear and grade, 2 = wall construction, 3 = roofing
    construction, 4 = flooring construction, 5 = lighting installation,
    6 = finished/maintenance).
       Index As Integer                        ' Current position in
    block type array.
       GradingTarget As Long                   ' Elevation in inches to
    grade landscape and/or create block PWOs at.
       CenterX As Integer                      ' Build site center
    coordinate.
       CenterY As Integer                      ' Build site center
    coordinate.
       Grading As PlanGradingStructure[]       ' Grading blocks.
       Wall As PlanWallStructure[]             ' Wall blocks.
       Roofing As PlanRoofingStructure[]       ' Roofing blocks.
       Flooring As PlanFlooringStructure[]     ' Flooring blocks.
       Lighting As PlanLightingStructure[]     ' Lighting blocks.
       Portal As PlanPortalStructure[]         ' Portal blocks.
       Furnishing As PlanFurnishingStructure[] ' Furnishing blocks.
       WallHeightTallest As Single             ' Maximum wall target
    height (temporarily used to set roofing height).
       WallHeightTotal As Single               ' Total height in feet of
    all walls (used to know when wall construction has been completed).
       WallHeightCurrent As Single             ' Current height in feet
    of all walls constructed (used to know when wall construction has
    been completed).
    End Struct
    Public Plan[10] As Struct PlanStructure


When I assign the value 180.2 to the Orientation property (type Single) 
of PlanPortalStructure like this:

    Plan[p].Portal[Index].Orientation = 180.2


the value is assigned as 180.1999969.

Any idea why this is happening?Seems strange that explicitly setting a 
type Single to a value would immediately cause precision to be lost; 
maybe it has to do with a structure being embedded in another structure?

-- 
Kevin Fishburne
Eight Virtues
www: http://sales.eightvirtues.com
e-mail: sales at ...1887...
phone: (770) 853-6271





More information about the User mailing list