LogFAQs > #979559598

LurkerFAQs, Active Database ( 12.01.2023-present ), DB1, DB2, DB3, DB4, DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicWriting an NES emulator ama
Yellow
03/25/24 6:31:47 PM
#21:


I'm about to make a YouTube video essay on why you should never never never use float. In response to this.

https://www.youtube.com/watch?v=E7kCFkFi0Cc

What takes up more space, float or double? What about a float[100] and a double[100]? What about a bool[100]? Ask any programmer and 95% of them will tell you the wrong answer. All of them take up the exact same amount of space, array or not. A bool, something that's either true or false, takes up 64 bits in memory.

A bool[3] in memory looks like this;
00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000001 true
00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000001 true
00000000_00000000_00000000_00000000_00000000_00000000_00000000_00000001 true

An int[3] in memory looks like this;
00000000_00000000_00000000_00000000_11111111_11111111_11111111_11111111 0xffffffff
00000000_00000000_00000000_00000000_11111111_11111111_11111111_11111111 0xffffffff
00000000_00000000_00000000_00000000_11111111_11111111_11111111_11111111 0xffffffff

And these tests prove that they're not more demanding;
https://pastebin.com/3MVXpUik

So why would you ever use float? You wouldn't. You would only assume you are suffering from Dunning Kruger because literally everyone gets this wrong. float is a relic of 32-bit machines. double, originally took up 2 address spaces. Today it only takes up one. And your CPU does work on all bits synchronously, so it literally does not matter how many of those 64 bits you use in regards to speed or memory usage.

Likewise! long is objectively superior to int, another type that (if not for legacy costs) should not be used anymore!

Why is it that every top voted answer on StackOverflow suggests saving memory/performance by using int/float??? All these valuetypes are lies, each and every one of them is a long on your 64-bit machines.

Why is it that modern game engines still use float for X/Y/Z? They should absolutely not. The only engine I know of that gets this right is Unreal Engine.

To "fix" starfield you have to modify the assembly of the engine and force it to use double instead of float. Then you can have planet sized worlds. You will have to patch it a lot but it's not impossible.

---
https://www.youtube.com/watch?v=5C_Wrt6pNSw
... Copied to Clipboard!
Topic List
Page List: 1