1. Post #281
    Gold Member
    Rohans's Avatar
    September 2010
    172 Posts
    float precision issue
    Math.Floor() shouldn't do anything to a whole number, that's no precision issue.
    Reply With Quote Edit / Delete Canada Show Events Disagree Disagree x 7 (list)

  2. Post #282
    Gold Member
    esalaka's Avatar
    July 2007
    10,249 Posts
    .95f * 100 is not a whole number.

    Edited:

    In fact, I believe in single precision it is just below 95
    Reply With Quote Edit / Delete Finland Show Events Late Late x 1Informative Informative x 1Agree Agree x 1 (list)

  3. Post #283
    Richy19's Avatar
    May 2010
    5,413 Posts
    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: http://www.terraria.org/

    Edit: By community, I just mean some sort of Github project that we could fork off of and merge as wanted.
    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++
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 1 (list)

  4. Post #284
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,503 Posts
    Why restrict IDE choice?
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 6 (list)

  5. Post #285
    Facepunch Staff
    layla's Avatar
    March 2010
    2,581 Posts
    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).
    You can also just reuse the same buffer by adding faces where other faces got removed.
    Reply With Quote Edit / Delete United Kingdom Show Events

  6. Post #286
    Gold Member
    ThePuska's Avatar
    October 2005
    3,451 Posts
    Just tested, it is indeed a float precision issue.

    I don't think so.

    Reply With Quote Edit / Delete Finland Show Events Informative Informative x 6Zing Zing x 1Agree Agree x 1 (list)

  7. Post #287
    www.bff-hab.de
    Dennab
    February 2009
    7,832 Posts
    Why restrict IDE choice?
    Maybe so the project files are interchangeable?
    Reply With Quote Edit / Delete Germany Show Events Dumb Dumb x 3 (list)

  8. Post #288
    Gold Member
    danharibo's Avatar
    July 2006
    4,498 Posts
    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++
    More like CMake if C# or CMake if C++
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 1 (list)

  9. Post #289
    Gold Member

    October 2008
    3,838 Posts
    I don't think so.

    I think it's weird enough that those two lines output a different number.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 11 (list)

  10. Post #290
    TVC

    April 2010
    300 Posts

    Why real developers go for C/C++. :smug:

    Put cast in there just to make sure.

    More like CMake if C# or CMake if C++
    I like Premake 4, it's Lua. :biggrin:
    Reply With Quote Edit / Delete Australia Show Events Dumb Dumb x 9Funny Funny x 1 (list)

  11. Post #291
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    I don't think so.

    Reply With Quote Edit / Delete United States Show Events Informative Informative x 5Funny Funny x 1 (list)

  12. Post #292
    Gold Member
    danharibo's Avatar
    July 2006
    4,498 Posts
    what.

    Seriously, what.
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 4 (list)

  13. Post #293
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    what.

    Seriously, what.
    That is what it is compiled into.
    Reply With Quote Edit / Delete United States Show Events Informative Informative x 4 (list)

  14. Post #294
    Gold Member
    Rohans's Avatar
    September 2010
    172 Posts
    So uh, a float CAN contain 95 as a whole but it doesn't when it's supposed to?
    Reply With Quote Edit / Delete Canada Show Events

  15. Post #295
    Gold Member

    October 2008
    3,838 Posts
    I think we might just have found the first bug ever in C#.
    Reply With Quote Edit / Delete United States Show Events Agree Agree x 14Programming King Programming King x 2Dumb Dumb x 1Disagree Disagree x 1 (list)

  16. Post #296
    Gold Member
    danharibo's Avatar
    July 2006
    4,498 Posts
    That is what it is compiled into.
    I was 'what'ing the compiler's choice to turn 0.95 into.. that.

    Edited:

    I think we might just have found the first bug ever in C#.
    I doubt it.
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 9 (list)

  17. Post #297
    Gold Member
    ThePuska's Avatar
    October 2005
    3,451 Posts
    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
    Reply With Quote Edit / Delete Finland Show Events Disagree Disagree x 1 (list)

  18. Post #298
    Gold Member
    Rohans's Avatar
    September 2010
    172 Posts
    I think we might just have found the first bug ever in C#.

    Prints 94 and 95, remove the casts and it prints 95 and 95. wat
    Reply With Quote Edit / Delete Canada Show Events

  19. Post #299
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    Okay it has to do with going from a float to a double.

    0.95 float turns into a 0.949999988079071 double.

    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
    What .net version because the C#4 compiler is just optimizing it out for me, even in debug.
    Reply With Quote Edit / Delete United States Show Events

  20. Post #300
    Gold Member
    thomasfn's Avatar
    July 2008
    2,966 Posts
    What about:

    Code:
    Console.WriteLine(Math.Floor(.95f * 100f));
    Will that have any effect?
    Reply With Quote Edit / Delete United Kingdom Show Events Disagree Disagree x 1 (list)

  21. Post #301
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    Maybe so the project files are interchangeable?
    As long as everyone sets up their IDEs to use the same source files, you can have as many project files as you want. It really doesn't matter.
    Reply With Quote Edit / Delete United Kingdom Show Events Agree Agree x 1 (list)

  22. Post #302
    Gold Member
    ThePuska's Avatar
    October 2005
    3,451 Posts
    Okay it has to do with going from a float to a double.

    0.95 float turns into a 0.949999988079071 double.



    What .net version because the C#4 compiler is just optimizing it out for me, even in debug.
    3.5
    Reply With Quote Edit / Delete Finland Show Events

  23. Post #303
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    Maybe resharper is getting rid of it.

    Anyways the compiler most likely is storing the result in a double when it does the compile time evaluation. Resulting in .95 becoming .949 and then multiplying by 100.
    Reply With Quote Edit / Delete United States Show Events

  24. Post #304
    LOL
    Dennab
    August 2009
    2,070 Posts
    What about:

    Code:
    Console.WriteLine(Math.Floor(.95f * 100f));
    Will that have any effect?
    Reply With Quote Edit / Delete United States Show Events

  25. Post #305
    Gold Member
    danharibo's Avatar
    July 2006
    4,498 Posts
    As long as everyone sets up their IDEs to use the same source files, you can have as many project files as you want. It really doesn't matter.
    But that's a stupid idea, Use CMake or your obscure build system/Project generator of choice.
    Reply With Quote Edit / Delete United Kingdom Show Events

  26. Post #306
    LOL
    Dennab
    August 2009
    2,070 Posts
    And..doubles work

    Reply With Quote Edit / Delete United States Show Events

  27. Post #307
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    I think we're all in agreement that floats store a value slightly under 0.95, and doubles do not

    Then again, I don't have any content either so... I guess I'm not really helping.
    Reply With Quote Edit / Delete United Kingdom Show Events Disagree Disagree x 1 (list)

  28. Post #308
    Gold Member
    esalaka's Avatar
    July 2007
    10,249 Posts
    WAYWO v17 - Rounding to 95

    Edited:

    Constant floating point numbers are (In (many of) the C family languages) doubles by default, hence it working without the 'd'.

    Conclusion: fuck floats they can't do 95 right
    Reply With Quote Edit / Delete Finland Show Events Agree Agree x 13Funny Funny x 5 (list)

  29. Post #309
    Shanethe13's Avatar
    May 2008
    746 Posts
    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++
    Oh, of course. I was just throwing the idea out there. Without any planning there'd be a near zero-chance of getting anything done. Restricting the IDE sounds a bit much though. I'd personally be fine with any language: I don't have as much experience in the C family of languages, but how hard can it be?
    Reply With Quote Edit / Delete Canada Show Events Agree Agree x 1 (list)

  30. Post #310
    Icedshot's Avatar
    April 2010
    2,361 Posts
    Oh, of course. I was just throwing the idea out there. Without any planning there'd be a near zero-chance of getting anything done. Restricting the IDE sounds a bit much though. I'd personally be fine with any language: I don't have as much experience in the C family of languages, but how hard can it be?
    Considering that 95 rounds to 94, probably quite hard
    Reply With Quote Edit / Delete United Kingdom Show Events Funny Funny x 8 (list)

  31. Post #311
    ColdFusion's Avatar
    December 2009
    2,227 Posts
    You can vote only if you submit a game.
    It wasn't always like this.
    Reply With Quote Edit / Delete Netherlands Show Events

  32. Post #312
    Gold Member

    October 2008
    3,838 Posts
    WAYWO v17 - Rounding to 95

    Edited:

    Constant floating point numbers are (In (many of) the C family languages) doubles by default, hence it working without the 'd'.

    Conclusion: fuck floats they can't do 95 right
    Maybe it has something to do with Windows 95?
    Reply With Quote Edit / Delete United States Show Events Funny Funny x 1Dumb Dumb x 1Informative Informative x 1 (list)

  33. Post #313
    q3k
    Gold Member
    q3k's Avatar
    October 2009
    921 Posts
    I'd like to see how the CIL bytecode looks like...
    Reply With Quote Edit / Delete Poland Show Events Late Late x 1 (list)

  34. Post #314
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    Maybe it has something to do with Windows 95?
    Next thing we know, it'll turn out that C# is just some massive ARG leading up to the release of Microsoft's next product...
    Reply With Quote Edit / Delete United Kingdom Show Events Funny Funny x 20Agree Agree x 1Winner Winner x 1 (list)

  35. Post #315
    Irtimid's Avatar
    April 2008
    239 Posts
    Just added zlib compression to my package format, so far it's doing very well reducing the file size one kilobyte.
    Reply With Quote Edit / Delete Canada Show Events Winner Winner x 2 (list)

  36. Post #316
    Eudoxia's Avatar
    July 2009
    6,009 Posts
    I'm writing a little Interactive Fiction parser. I [mostly] don't care about the Interactive Fiction part, but disassembling natural language always intersted me
    Reply With Quote Edit / Delete Uruguay Show Events Programming King Programming King x 2 (list)

  37. Post #317
    Gold Member
    BackwardSpy's Avatar
    May 2008
    6,563 Posts
    Natural Language systems are very interesting indeed. I still look forward to the day when I can command my computer to do things, in common English instead of specific, pre-recorded commands...

    Edit:
    I really hope they don't get clever enough to talk back at you though

    "Computer, open Steam"
    ...
    "no"
    Reply With Quote Edit / Delete United Kingdom Show Events Funny Funny x 19 (list)

  38. Post #318
    Gold Member
    esalaka's Avatar
    July 2007
    10,249 Posts
    Sorta like this?

    Code:
    $ vim
    Fuck you, use emacs
    $
    Reply With Quote Edit / Delete Finland Show Events Funny Funny x 24Agree Agree x 1 (list)

  39. Post #319
    Hates php
    high's Avatar
    May 2006
    2,415 Posts
    Looking at .NETs System.ServiceModel (mono supports it <3). It looks very nice. Kinda weird though.

    host = new ServiceHost(typeof(WebHost), new Uri("net.tcp://localhost:5123/"));
    host.AddServiceEndpoint(typeof(IWebHost), new NetTcpBinding(SecurityMode.None), "servicename");

    It creates an instance of WebHost and calls the method that the client called. Was kinda expecting to give it a handler instance. I am assuming you can still do that, this is just the default behavior. Still a hell of a lot better than writing the server end in php and translating between the 2.
    Reply With Quote Edit / Delete United States Show Events

  40. Post #320
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    I decided to make an add function for 8 bit numbers that only uses logic operators .

    // Headers
    #include <iostream>
    
    // Binary addition
    void add( bool a[], bool b[], bool r[] )
    {
    	bool c;
    	r[0] = a[0] ^ b[0];
    	c = a[0] & b[0];
    	r[1] = ( a[1] ^ b[1] ) ^ c;
    	c = ( c & ( a[1] | b[1] ) ) | ( a[1] & b[1] );
    	r[2] = ( a[2] ^ b[2] ) ^ c;
    	c = ( c & ( a[2] | b[2] ) ) | ( a[2] & b[2] );
    	r[3] = ( a[3] ^ b[3] ) ^ c;
    	c = ( c & ( a[3] | b[3] ) ) | ( a[3] & b[3] );
    	r[4] = ( a[4] ^ b[4] ) ^ c;
    	c = ( c & ( a[4] | b[4] ) ) | ( a[4] & b[4] );
    	r[5] = ( a[5] ^ b[5] ) ^ c;
    	c = ( c & ( a[5] | b[5] ) ) | ( a[5] & b[5] );
    	r[6] = ( a[6] ^ b[6] ) ^ c;
    	c = ( c & ( a[6] | b[6] ) ) | ( a[6] & b[6] );
    	r[7] = ( a[7] ^ b[7] ) ^ c;
    }
    
    // Helpers
    void dec2bin( unsigned char in, bool out[] )
    {
    	out[0] = in & 1; out[1] = in & 2; out[2] = in & 4; out[3] = in & 8; out[4] = in & 16; out[5] = in & 32; out[6] = in & 64; out[7] = in & 128;
    }
    
    unsigned char bin2dec( bool in[] )
    {
    	return in[0] + in[1]*2 + in[2]*4 + in[3]*8 + in[4]*16 + in[5]*32 + in[6]*64 + in[7]*128;
    }
    
    // Example
    int main()
    {
    	bool res[8];
    	bool a[8];
    	bool b[8];
    
    	dec2bin( 117, a );
    	dec2bin( 25, b );
    
    	add( a, b, res );
    
    	std::cout << (int)bin2dec( res ) << std::endl;
    
    	std::cin.get();
    	return 0;
    }

    Eventually I want to make my own ALU by implementing the logic with electronics. (That is why I'm using arrays)
    Reply With Quote Edit / Delete Netherlands Show Events Funny x 6Winner x 3Dumb x 1Friendly x 1Programming King x 1Artistic x 1 (list)