Where can I find the maximum and minimum values that various types can store? And an epsilon value for floats?
I'm looking for something like C's
limits.h, but for Solidity / EVM.
I assume you mean the integer types, because those are really the only types in Solidity that have a maximum and a minimum.
Solidity does not support floating point types, and most likely will never because they are considered not to be precise enough. Ethereum contracts need to be 100% deterministic, and always run the same way on all hardware.
Solidity will in the future support fixed-point types, but it doesn't yet.
Once you know the amount of bits your integer has, you can easily calculate the minimum and maximum using bitwise arithmetic:
int256 constant INT256_MIN = int256(uint256(1) << 255); int256 constant INT256_MAX = int256(~(uint256(1) << 255)); uint256 constant UINT256_MIN = 0; uint256 constant UINT256_MAX = ~uint256(0);
All the bitwise shifting is done on unsigned ints to avoid any special behaviour on the sign bit.