RUVIDEO
Поделитесь видео 🙏

7. Named Constants & Integer Division

Hello everyone, today we are going to cover named constants and integer division. First, name constants are declared "variables" who's value is known ahead of time and does not change, hence the name constant. Their syntax is the keyword "const" followed by the data type of choice, then a name usually with the convention of all upper cases separated by underscores, and finally its initialization. In our program we are able to convert any given dozens of eggs into the single count of eggs. To process the data we multiply the number of dozens by 12 which is the conversion unit for a dozen. However, 12 is a "magic number" because it appeared without explanation. It is better practice to use replace magic numbers with named constants such as SINGLES_PER_DOZEN. Working when you are working with teammates that need to readily understand your code, it will significantly delay their work if they have to use context clues to understand your code.

Next, integer division is when you divide two integers and the result is truncated. Truncation means that any decimal portion is removed and only the integer is left as the result. This is why we see the strange example where "10 / 20 = 0" because it is actually equal to "0.5" but the decimal is removed and we are left with 0 as the answer. We can receive the expected output by either declaring one of the variables as a double and that will implicitly convert the result to a double. We may also choose to perform casting whether that is the C++ or older C style casting. I simply wanted to expose you to the concept of casting, however please do not worry too much as we will cover it in greater detail at a later time.

I encourage you to watch my next video where will we apply the topics we have learned with a practice problem. Thank you for watching and if you enjoyed the video and would like more programming content, please like, share, and subscribe! :)

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «7. Named Constants & Integer Division», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.