[JIRA] Commented: (SVC-3665) Float rounding errors under MONO

Contagious Republic (JIRA) no-reply at lindenlab.cascadeo.com
Fri Nov 27 07:11:03 PST 2009


    [ http://jira.secondlife.com/browse/SVC-3665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=149138#action_149138 ] 

Contagious Republic commented on SVC-3665:
------------------------------------------

// Here is Contagious Republic's encounter with the bug
//
// Suspected: the 'x' variable is float-sized; the constant expression is internally a double during the !=
// they're different because the double is more precise, or it's rounded differently than being put in a float variable.
// I wrote several compilers, I see no reason for the bug to stay in a non-optimizing compiler like mono.

default
{
    state_entry()
    {
        llSay(0, "Hello, Avatar!");
    }

    touch_start(integer total_number)
    {
        float x = (0.863 * 360.0);
        if (x != (0.863 * 360.0))
        {
            llOwnerSay("This is not a standard rounding error, it's inconsistent with itself");
        }
        else
            llOwnerSay("Normal");
    }
}

> Float rounding errors under MONO
> --------------------------------
>
>                 Key: SVC-3665
>                 URL: http://jira.secondlife.com/browse/SVC-3665
>             Project: 2. Second Life Service - SVC
>          Issue Type: Bug
>          Components: Scripts
>    Affects Versions: 1.24 Server
>            Reporter: Jathra Vanmoer
>            Priority: Major
>
> This is a major bug!  Check this out..
> {code}
> default
> {
>     touch_start(integer total_number)
>     {
>         float rand = -1000000000 + llFrand(2000000000);
>         
>         llSay(0, (string)rand);
>         llSay(0, (string)llFloor(rand));
>         llSay(0, (string)llRound(rand));
>         llSay(0, (string)((integer)rand));
>     }
> }
> {code}
> Output:
> [2:10]  Object: 823925400.000000
> [2:10]  Object: 823925376
> [2:10]  Object: 823925376
> [2:10]  Object: 823925376
> [2:10]  Object: -715199200.000000
> [2:10]  Object: -715199232
> [2:10]  Object: -715199232
> [2:10]  Object: -715199232
> [2:10]  Object: 34822210.000000
> [2:10]  Object: 34822208
> [2:10]  Object: 34822208
> [2:10]  Object: 34822208
> [2:10]  Object: 181815600.000000
> [2:10]  Object: 181815552
> [2:10]  Object: 181815552
> [2:10]  Object: 181815552
> Under mono converting from float to integer causes a rounding error which gives you the wrong value!  This is a major issue which does not happen under LSL and its breaking my products which I am trying to convert to mono!  Please fix this!
> On further examination it seems floats just flat out aren't rounding right.
> Seems to round off the first 3 digits even if fed in a non random number it will round to 0200 or something at the end then give you something completely different when converted to an integer.. this is a major problem with potential to break a lot of products which doesn't happen under LSL.
> PS: If this has already been reported I'm sorry I did a quick search and didn't see anything.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.secondlife.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the Jira-notify mailing list