Generally a CMOS buffer, or two inverters in series, will do what you ask when powered from a precise reference supply. Anything more than 0.7 Vdd will give you a high output, and anything less than 0.3 Vcc will give you a low. Both will be very close (millivolts) to the supply rails if there is little loading. If you need to accommodate lower inputs you can use something like a voltage translator, an HCT gate or even a CMOS LVDS receiver.
For more current and little voltage drop you can use a CMOS-output MOSFET gate driver- some of them can drive very high currents and have an output resistance in the ohms rather than more like 100 ohms+.
Using a precise 5V reference for the buffer supply and feeding it a 5V-ish digital PWM input can give you a precise analog voltage when filtered.