educative.io

I don't understand how this generates an error

int main() {
  unsigned float number = 18.9;  
cout << "Number = " << number << endl;

}

I am very confused as to how this generates an error. It's type is float, so it can have a decimal. It is a positive number, so it should be able to output 18.9. So why does it generate an error when compiled?

Why C++ doesn’t have support for unsigned floats is because there are no equivalent machine code operations for the CPU to execute. So it would be very inefficient to support it.