Skip to content

fix BDouble init?(_ nStr: String) when String has scientific notation#81

Merged
mkrd merged 3 commits intomkrd:masterfrom
piggyse:feature/scientific-notation-init
Jan 8, 2024
Merged

fix BDouble init?(_ nStr: String) when String has scientific notation#81
mkrd merged 3 commits intomkrd:masterfrom
piggyse:feature/scientific-notation-init

Conversation

@piggyse
Copy link
Copy Markdown

@piggyse piggyse commented Jan 8, 2024

Hi!
I think there is bug when init BDouble when String has scientific notation
So i fixd some logic and added tests
My changes passed all the Unit tests

Bug Example

       // MARK: Fail
        let a = BDouble("+2.46e+3")
        let b = BDouble(2460)
        XCTAssertEqual(a, b)
        XCTAssertEqual(a?.decimalDescription, b.decimalDescription)

        let c = BDouble("-2.46e+1")
        let d = BDouble(-24.6)
        XCTAssertEqual(c, d)

        XCTAssertEqual(c?.decimalDescription, d.decimalDescription)

        // MARK: Success
        let e = BDouble("-2.46e-2")
        let f = BDouble(-0.0246)
        XCTAssertEqual(e, f)
        XCTAssertEqual(e?.decimalDescription, f.decimalDescription)

@mkrd mkrd merged commit 78dcdcb into mkrd:master Jan 8, 2024
@mkrd
Copy link
Copy Markdown
Owner

mkrd commented Jan 8, 2024

@piggy-park Thanks for your contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants