Skip to content

double-precision properties fail to hold value through PropertySetter and PropertyGetter #2

@Place1

Description

@Place1

Related test case:

expect(win.opacity).toEqual(0.33);

output:

expect(received).toEqual(expected)
    Expected value to equal:
      0.33
    Received:
      0.32941176470588235

It would be interesting to get some more eyes on this issue. I've been using GDB to inspect the values in various places.

I found that in the PropertySetter the value was 0.33000000000000002 i.e. calling value->NumberValue() gave that number. This means that V8 is converting the 0.33 from the test-case's source code into 0.33000000000000002 as a c++ double.

After the GIRValue::ToGValue() calling g_value_get_double(&gvalue) returned the same 0.33000000000000002 value; this is good, at least our V8 -> GValue conversion is working as expected!

I believe the problem is in the PropertyGetter. After the call to g_object_get_property() a call to g_value_get_dobule(&gvalue) gives the value of 0.32941176470588235; this is the same number that the test case shows so we know that the GValue -> V8 conversion is working as well!

So, Is there a problem with precision or handling of V8 numbers, or does the window.opacity property do something funny under-the-hood in GTK land? I'm suspecting the latter is the case after my debugging session, but I don't want to change the test-case until we're sure! This is weird behaviour and we need to make sure it's not a bug with our bindings. If it's a bug with GTK, then that also sucks but at least we can push the work up-stream :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions