Skip to content

Conversation

@mbgonicus
Copy link

The xls standard allows to save a decimal number like 1.75 as an integer, multiplied by 100. The current implementation did neither detect this as an integer nor as a float and subsequently returns the default value 0.

This fix adds the case to RKNumber's Float64() method in order to retrieve the value correctly as float.

It also adds a test and a new xls file in testdata for this case. I did not dare to touch the existing xls files to not corrupt the saved data (I only have LibreOffice and it might do funky things). So if you do not like a new file there, please feel free to edit this PR to your liking.

The xls standard allows to save a decimal number like 1.75 as an
integer, multiplied by 100. The current implementation did neither
detect this as an integer nor as a float and subsequently returns the
default value 0.

This fix adds the case to RKNumber's Float64() method in order to
retrieve the value correctly as float.
@pbnjay
Copy link
Owner

pbnjay commented Nov 16, 2023

Hmm thanks for catching that! I think we should cover the remaining case also, can you add that in?

if (r&1) == 0 && (r&2) != 0 {
    return float64(val)
}

@mbgonicus
Copy link
Author

Hmm thanks for catching that! I think we should cover the remaining case also, can you add that in?

if (r&1) == 0 && (r&2) != 0 {
    return float64(val)
}

But that case would mean it is a signed integer and should be handled via the Int() method there? IsInteger() would be true in that case anyway.

@mbgonicus
Copy link
Author

@pbnjay btw the failing tests are failing already, i.e. are not failing due to my changes.

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.

2 participants