Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increment/Decrement on NumberInterface creates weird precision #327

Closed
sgramsay opened this issue Nov 1, 2023 · 2 comments
Closed

Increment/Decrement on NumberInterface creates weird precision #327

sgramsay opened this issue Nov 1, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@sgramsay
Copy link

sgramsay commented Nov 1, 2023

Taking the below example node code, utilising the increment/decrement handles results in weird precision issues, am I missing something or is this a bug? Entering numbers directly is fine.

image

import { defineNode, NodeInterface, NumberInterface, SelectInterface } from "baklavajs";

export default defineNode({
    type: "MathNode",
    inputs: {
        number1: () => new NumberInterface("A", 1),
        number2: () => new NumberInterface("B", 10),
        operation: () => new SelectInterface("Operation", "Add", ["Add", "Subtract"]).setPort(false),
    },
    outputs: {
        output: () => new NodeInterface("Output", 0),
    },
    calculate({ number1, number2, operation }) {
        let output: Number
        console.log(number1,"-",number2) // Outputs  1.6000000000000005 '0' - 10
        if (operation === "Add") {
            output = number1 + number2;
        } else if (operation === "Subtract") {
            output = number1 - number2;
        } else {
            throw new Error("Unknown operation: " + operation);
        }
        return { output };
    },
});
@sgramsay
Copy link
Author

sgramsay commented Nov 1, 2023

V2 Beta 5 BTW

@newcat newcat added the bug Something isn't working label Jan 1, 2024
@newcat
Copy link
Owner

newcat commented Jan 2, 2024

Fixed in v2.3.0

@newcat newcat closed this as completed Jan 2, 2024
@newcat newcat added this to V2 Apr 9, 2024
@newcat newcat moved this to Done in V2 Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants