Does C allow implicit casting/conversion from float to an int?

At its core, all data is stored in the same one's and zero's so a program needs a way to differentiate between one type of data and another. (eg. integer vs. float) The internals of a program store variables in a such a way such that it indicates what the data type of that variable is. So when you try to access that data, you don't get the wrong type of value. This is called strict data typing. C allows you to change that data type and that process is called casting. (eg. double_variable = (double) int_variable) There are some compiler rules which dictate in which direction you can cast a data type into. You would have to look up the rules for your programming language if there are any.

/r/C_Programming Thread Parent