vorbis icon indicating copy to clipboard operation
vorbis copied to clipboard

fix of implicit type conversion.

Open ihsinme opened this issue 5 years ago • 14 comments

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 avatar Dec 29 '20 10:12 ihsinme

good day. somebody will look at my PR.

ihsinme avatar Jan 13 '21 06:01 ihsinme

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

petterreinholdtsen avatar Jan 18 '21 15:01 petterreinholdtsen

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 avatar Feb 05 '21 13:02 ihsinme

is this PR still relevant?

ihsinme avatar Feb 16 '21 06:02 ihsinme

I have to do something to make this PR useful.

ihsinme avatar May 17 '21 16:05 ihsinme

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?

petterreinholdtsen avatar May 17 '21 18:05 petterreinholdtsen

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?

ihsinme avatar May 17 '21 19:05 ihsinme

[ihsinme]

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?

I am not the maintainer of vorbis, so I do not really have an opinion on this.

-- Happy hacking Petter Reinholdtsen

petterreinholdtsen avatar May 17 '21 21:05 petterreinholdtsen

@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?

rillian avatar May 19 '21 19:05 rillian

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

rillian avatar May 19 '21 19:05 rillian

@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.

ihsinme avatar May 21 '21 18:05 ihsinme

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.

rillian avatar Jun 04 '21 04:06 rillian

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

ihsinme avatar Jun 04 '21 06:06 ihsinme

is there any news on this PR?

ihsinme avatar Feb 11 '22 07:02 ihsinme