Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006160opensim[REGION] Script Functionspublic2012-08-15 04:082012-08-20 03:00
ReporterSignpostMarv 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Statuspatch feedbackResolutionopen 
PlatformOSOS Version
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0006160: llFloor operates on doubles rather than floats, producing differences in expected results
DescriptionThe repro script indicates 27 for all values in Second Life, whereas OpenSim indicates 27 for the value of a and 26 for the llFloor() results.

The attached patch changes the behaviour of llFloor() in OpenSim to match the behaviour of llFloor() in Second Life
Steps To Reproducedefault
{
    touch_start(integer t)
    {
        float a = 26.9999995;
        llSay(0, llList2CSV([
            a,
            llFloor(a),
            llFloor(26.9999995)
        ]));
    }
}
TagsNo tags attached.
Git Revision or version numberdc82ad0
Run ModeStandalone (1 Region) , Grid (1 Region per Sim)
Physics EngineBasicPhysics
Script Engine
Environment.NET / Windows32, .NET / Windows64
Mono VersionNone
Viewer
Attached Filespatch file icon llFloor-precision-problem.patch [^] (1,129 bytes) 2012-08-15 04:08 [Show Content]
patch file icon llFloor-Ceil-Round-precision.patch [^] (1,674 bytes) 2012-08-20 03:00 [Show Content]

- Relationships

-  Notes
(0022091)
justincc (administrator)
2012-08-15 14:26

It seems to me that this points to a more fundamental issue. If llFloor() is cast internally from double to float then llCeil(), llRound(), etc. should be as well.

But then one could ask why LSL_Float was modelled internally using a double rather than a float and save all this and future casting.
(0022092)
SignpostMarv (reporter)
2012-08-15 14:32

26.9999995 should ceil to 27 is 26.9999995 or float-cast to 27.

I can only think llRound would have issues if it was fed a double greater than 0.5 that typecast to float would be less than 0.5
(0022112)
justincc (administrator)
2012-08-17 15:55

No, there are other cases. For instance, in SL

default
{
    touch_start(integer t)
    {
        float a = 27.0000002;
        llSay(0, llList2CSV([
            a,
            llCeil(a),
            llCeil(27.0000002)
        ]));
    }
}

Object: 27.000000, 27, 27

but will return

Primitive: 27.000000, 28, 28

because SL casts the literals to floats with less precision than doubles. It wouldn't surprise me if there were lots of examples of this though I admit I haven't looked further.
(0022113)
justincc (administrator)
2012-08-17 15:56

Which is why I think it would be much better to cast these straight off to floats rather than doubles if one really wants to be LSL compliant. Whether this is a good idea or not is another question.
(0022387)
SignpostMarv (reporter)
2012-08-20 03:00

New test script:

default
{
    touch_start(integer t)
    {
        float a = 26.9999995;
        llSay(0, llList2CSV([
            a,
            llFloor(a),
            llFloor(26.9999995)
        ]));

        a = 27.0000002;
        llSay(0, llList2CSV([
            a,
            llCeil(a),
            llCeil(27.0000002)
        ]));

        a = 26.4999999;
        llSay(0, llList2CSV([
            a,
            llRound(a),
            llRound(26.4999999)
        ]));
    }
}

- Issue History
Date Modified Username Field Change
2012-08-15 04:08 SignpostMarv New Issue
2012-08-15 04:08 SignpostMarv File Added: llFloor-precision-problem.patch
2012-08-15 04:08 SignpostMarv Status new => patch included
2012-08-15 14:26 justincc Note Added: 0022091
2012-08-15 14:32 SignpostMarv Note Added: 0022092
2012-08-17 15:55 justincc Note Added: 0022112
2012-08-17 15:56 justincc Note Added: 0022113
2012-08-18 04:32 DMX04 Issue cloned: 0006180
2012-08-20 03:00 SignpostMarv File Added: llFloor-Ceil-Round-precision.patch
2012-08-20 03:00 SignpostMarv Note Added: 0022387
2012-08-20 03:00 SignpostMarv Status patch included => patch feedback


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker