Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Lerp and int/float conversions
#2
Don't worry! I just converted every parameter in "lerp" to be floats, no more ints, and the effect is perfect!

*facepalm*

I also learnt an important difference between C++ and C# here;
  • With C++, if you throw even one float variable into the calculation, the output will be a float. But if all of them are ints, the output will be an int, even if accuracy will be lost (eg. a division).
  • With C#, if you do any sort of mixing between floats and ints, the compiler itself stops and complains that you can't automatically just mix them, you need to step in and manually cast each one to a float or int before it will proceed, forcing you to make a decision.

Man, I think I prefer the way C++ works here. It does the calculation using the most accurate variable type in the equation - this is simple to remember, and I can always just cast down to a simpler type if I need it. I know C# is attempting to be "safer" by asking you to manually convert each one, but I think this just introduces more chances of human error...

I'm sure there's an argument for either way though.
Reply


Messages In This Thread
Lerp and int/float conversions - by Domarius - 07-18-2018, 10:17 AM
RE: Lerp and int/float conversions - by Domarius - 07-18-2018, 08:30 PM
RE: Lerp and int/float conversions - by megamarc - 07-18-2018, 11:23 PM
RE: Lerp and int/float conversions - by Domarius - 07-19-2018, 08:00 AM
RE: Lerp and int/float conversions - by megamarc - 07-19-2018, 03:58 PM
RE: Lerp and int/float conversions - by Domarius - 07-19-2018, 09:18 PM
RE: Lerp and int/float conversions - by megamarc - 07-24-2018, 02:02 AM
RE: Lerp and int/float conversions - by Domarius - 07-24-2018, 08:34 PM
RE: Lerp and int/float conversions - by megamarc - 08-07-2018, 06:39 AM
RE: Lerp and int/float conversions - by Domarius - 08-08-2018, 06:44 AM
RE: Lerp and int/float conversions - by megamarc - 08-09-2018, 06:30 AM
RE: Lerp and int/float conversions - by Domarius - 08-20-2018, 04:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)