Skip to content

fix of implicit type conversion.#79

Open
ihsinme wants to merge 3 commits into
xiph:mainfrom
ihsinme:master
Open

fix of implicit type conversion.#79
ihsinme wants to merge 3 commits into
xiph:mainfrom
ihsinme:master

Conversation

@ihsinme

@ihsinme ihsinme commented Dec 29, 2020

Copy link
Copy Markdown

in casting used in your code, first the result of division is converted to an integer type, with the loss of the fractional part, and then the integer is converted to a floating point type. I think this can be simply fixed.

@ihsinme

ihsinme commented Jan 13, 2021

Copy link
Copy Markdown
Author

good day.
somebody will look at my PR.

@petterreinholdtsen

Copy link
Copy Markdown
Contributor

Apparently the floor fix broke something. Btw, did you consider divinding by 2.0 instead of casting the value?

@ihsinme

ihsinme commented Feb 5, 2021

Copy link
Copy Markdown
Author

sorry for the long answer.
in fact, division by 2.0 is also a solution.
but I recommend using more explicit things that persist after refactoring.)
if you insist I will fix it to 2.0.

@ihsinme

ihsinme commented Feb 16, 2021

Copy link
Copy Markdown
Author

is this PR still relevant?

@ihsinme

ihsinme commented May 17, 2021

Copy link
Copy Markdown
Author

I have to do something to make this PR useful.

@petterreinholdtsen

Copy link
Copy Markdown
Contributor

Note, https://gitlab.xiph.org/xiph/vorbis/ is the upstream project, I've been told the github repository is a convenience copy. Perhaps it is an idea to submit the patch there?

@ihsinme

ihsinme commented May 17, 2021

Copy link
Copy Markdown
Author

Oh no. I don't have an account there. maybe a better idea would be if you fix the code there yourself.
do I close PR?

@petterreinholdtsen

petterreinholdtsen commented May 17, 2021 via email

Copy link
Copy Markdown
Contributor

@rillian

rillian commented May 19, 2021

Copy link
Copy Markdown
Contributor

@ihsinme Thanks for the patches. Can you say a bit more about what issue you're trying to address? Do you think this is a correctness problem? Are you trying to address warnings from a particular compiler?

Comment thread lib/envelope.c
considered prevoius-to-potential-trigger */
int stretch=max(VE_MINSTRETCH,ve->stretch/2);
float penalty=gi->stretch_penalty-(ve->stretch/2-VE_MINSTRETCH);
float penalty=gi->stretch_penalty-((float)(ve->stretch)/2-VE_MINSTRETCH);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stretch itself is calculated with integer division, so maybe that's a more accurate heuristic for the penalty?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you know better

@rillian

rillian commented May 19, 2021

Copy link
Copy Markdown
Contributor

The appveyor integration test failure is an unrelated issue fixed in 894d1b1. A rebase should complete without error.

@ihsinme

ihsinme commented May 21, 2021

Copy link
Copy Markdown
Author

@ihsinme Thanks for the patches. Can you say a bit more about what issue you're trying to address? Do you think this is a correctness problem? Are you trying to address warnings from a particular compiler?

the essence of the error is described in PR. this is an integer division, when a fraction is expected.

@rillian

rillian commented Jun 4, 2021

Copy link
Copy Markdown
Contributor

Just because the assigned variable is floating point doesn't mean the calculations must all be floating point. We are free to choose at what points integer inputs are converted. For example:

  • Floating point operations can preserve more precision in calculations.
  • Integer operations can be faster than floating point.
  • Floating point operations can be faster than checking for integer overflow.
  • Division by zero has different results based on the type of the operands.

Which of these criteria are most important varies. That's why I asked what specific issue you wanted to address.

@ihsinme

ihsinme commented Jun 4, 2021

Copy link
Copy Markdown
Author

Good day.
I see an error that the division will be integer.

@ihsinme

ihsinme commented Feb 11, 2022

Copy link
Copy Markdown
Author

is there any news on this PR?

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