• What are you working on? v17
    3,500 replies, posted
  • Avatar of danharibo
  • [QUOTE=Dlaor-guy;29419158]It appears that C#'s Floor function fails. [img_thumb]http://i.imgur.com/WTmYX.png[/img_thumb] [img_thumb]http://i.imgur.com/7pNJF.png[/img_thumb][/QUOTE] What if you floor 95 as a constant.
  • [QUOTE=danharibo;29419214]What if you floor 95 as a constant.[/QUOTE] Then it works, oddly enough... But seriously how is this even possible? [img]http://i.imgur.com/UUg8p.png[/img] Is it that the rounding functions fail or is it because of the lack of precision of floats?
  • Avatar of danharibo
  • [QUOTE=Dlaor-guy;29419258]Then it works, oddly enough... But seriously how is this even possible? [img_thumb]http://i.imgur.com/UUg8p.png[/img_thumb] Is it that the rounding functions fail or is it because of the lack of precision of floats?[/QUOTE] Well a float should contain the precise value of '95' and '80' without any issue.
  • Avatar of Shrapnel :3
  • It's probably floating point error when dividing to make "endPercent". The intellisense probably will round it.
  • Avatar of danharibo
  • [QUOTE=CarlBooth;29419357]You can't pass floats to Math.Floor you have to use Doubles or Decimals[/QUOTE] Well a double works exactly the same, It's just twice as big.
  • [QUOTE=CarlBooth;29419357]You can't pass floats to Math.Floor you have to use Doubles or Decimals[/QUOTE] Yeah, changing the percent variable to a double solved all the rounding errors. Never using floats again for stuff like this :v:
  • Avatar of CarlBooth
  • [QUOTE=danharibo;29419375]Well a double works exactly the same, It's just twice as big.[/QUOTE] It's dumb though and tries to convert between the two types rather than just adding the precision.
  • Avatar of TheBoff
  • [QUOTE=Dlaor-guy;29419392]Yeah, changing the percent variable to a double solved all the rounding errors. Never using floats again for stuff like this :v:[/QUOTE] At uni, I've just had a five hour course which in a nutshell was just: "floats are shit, just use double".
  • Avatar of high
  • [QUOTE=Dlaor-guy;29419258]Then it works, oddly enough... But seriously how is this even possible? [img_thumb]http://i.imgur.com/UUg8p.png[/img_thumb] Is it that the rounding functions fail or is it because of the lack of precision of floats?[/QUOTE] Just tested, it is indeed a float precision issue. [img]http://i53.tinypic.com/qxjcxl.png[/img]
  • [QUOTE=high;29419826]float precision issue[/QUOTE] Math.Floor() shouldn't do anything to a whole number, that's no precision issue.
  • Avatar of esalaka
  • .95f * 100 is not a whole number. [editline]25th April 2011[/editline] In fact, I believe in single precision it is [B]just below[/B] 95
  • Avatar of Richy19
  • [QUOTE=Shanethe13;29410057]Would anyone be interested in working on a community project akin to "A Whiff of Steam" from the Love2d forums? There's a lot of talented/hard-working people here, and with some organization, I think we could work together to make a really cool game. I for one, think it would be a blast to make some attempt at this sort of game: [url]http://www.terraria.org/[/url] Edit: By community, I just mean some sort of Github project that we could fork off of and merge as wanted.[/QUOTE] I love the idea but before we just jumpeed in, i think we should think of what language to use and what IDE, and library I vote for SFML, and VS if C# or CodeBlocks if C++
  • Avatar of Layla
  • [QUOTE=Night-Eagle;29415448]I have a separate VBO for every 8x8x128 voxels. I build them every time a change is made (dig block, place block). I use a triangle strip and render with glMultiDrawArrays(GL_TRIANGLE_STRIP, vaoFirst, vaoCount, vaoPrims); Oh, I also only build faces that are not adjacent to other faces (0 chance of being viewed). Instead of translating to X, Y, Z coordinates when checking for this visibility, I simplify the formula and keep it in terms of the index. I'm also doing some lazy culling and just rendering chunks within a 50.0 meter radius (will be larger when I get frustum culling and start running without the debugger) (each cube is 1.0 meter wide).[/QUOTE] You can also just reuse the same buffer by adding faces where other faces got removed.
  • Avatar of ThePuska
  • [QUOTE=high;29419826]Just tested, it is indeed a float precision issue. [img_thumb]http://i53.tinypic.com/qxjcxl.png[/img_thumb][/QUOTE] I don't think so. [img]http://img19.imageshack.us/img19/9716/floats.png[/img]
  • Avatar of DrLuke
  • [QUOTE=BlkDucky;29421300]Why restrict IDE choice?[/QUOTE] Maybe so the project files are interchangeable?
  • Avatar of danharibo
  • [QUOTE=Richy19;29420798]I love the idea but before we just jumpeed in, i think we should think of what language to use and what IDE, and library I vote for SFML, and VS if C# or CodeBlocks if C++[/QUOTE] More like CMake if C# or CMake if C++
  • [QUOTE=ThePuska;29421644]I don't think so. [img_thumb]http://img19.imageshack.us/img19/9716/floats.png[/img_thumb][/QUOTE] I think it's weird enough that those two lines output a different number.
  • [img]http://www.tvcdev.net/files/img/Screenshot-2011-04-26_01.41.12.png[/img] Why real developers go for C/C++. :smug: Put cast in there just to make sure. [QUOTE=danharibo;29421673]More like CMake if C# or CMake if C++[/QUOTE] I like Premake 4, it's Lua. :biggrin:
  • Avatar of high
  • [QUOTE=ThePuska;29421644]I don't think so. [img_thumb]http://img19.imageshack.us/img19/9716/floats.png[/img_thumb][/QUOTE] [img]http://i56.tinypic.com/5e7o88.png[/img]
  • Avatar of danharibo
  • [QUOTE=high;29421810][img_thumb]http://i56.tinypic.com/5e7o88.png[/img_thumb][/QUOTE] what. Seriously, what.
  • Avatar of high
  • [QUOTE=danharibo;29421819]what. Seriously, what.[/QUOTE] That is what it is compiled into.
  • [QUOTE=high;29421810][img_thumb]http://i56.tinypic.com/5e7o88.png[/img_thumb][/QUOTE] So uh, a float CAN contain 95 as a whole but it doesn't when it's supposed to?
  • Avatar of danharibo
  • [QUOTE=high;29421839]That is what it is compiled into.[/QUOTE] I was 'what'ing the compiler's choice to turn 0.95 into.. that. [editline]25th April 2011[/editline] [QUOTE=Dlaor-guy;29421857]I think we might just have found the first bug ever in C#.[/QUOTE] I doubt it.
  • Avatar of ThePuska
  • It works if you cast the float you calculate inside the floor function into a float manually Math.Floor((float)(.95f * 100)) for non-believers [img]http://img269.imageshack.us/img269/2519/floats2.png[/img]
  • [QUOTE=Dlaor-guy;29421857]I think we might just have found the first bug ever in C#.[/QUOTE] [img_thumb]http://imgur.com/ZN9HE.png[/img_thumb] Prints 94 and 95, remove the casts and it prints 95 and 95. wat
  • Avatar of high
  • Okay it has to do with going from a float to a double. 0.95 float turns into a 0.949999988079071 double. [QUOTE=ThePuska;29421872]It works if you cast the float you calculate inside the floor function into a float manually Math.Floor((float)(.95f * 100)) for non-believers [img_thumb]http://img269.imageshack.us/img269/2519/floats2.png[/img_thumb][/QUOTE] What .net version because the C#4 compiler is just optimizing it out for me, even in debug.
  • Avatar of thomasfn
  • What about: [code]Console.WriteLine(Math.Floor(.95f * 100f));[/code] Will that have any effect?