Java Basics - double float

preview_player
Показать описание
Intro to floating point numbers double and float
This video tells you some basic facts about Java floating point nubmers. It stresses their inability to precisely represent many of the numbers, the importance not to use them for money or other situations that require precision, and implications like Infinity and Nan. It also shows how to read in floating point numbers form the keyboard and how to print them with a rerstricted number of digits after the decimal point. The video includes code examples as well as a brief code demo at the end
Рекомендации по теме
Комментарии
Автор

Thanks. infinity and Nan are interesting points.

chittem-canada
Автор

I completed basic in java now I want to do some assignment if you have please guide

masoodsharcomputerscience
Автор

So, not everyone liked C-style printf() formatting, C++ certainly tried to displace it with << but lots of people hated sites and people who learned Java in the first 8 or 9 years won't be using it, and it definitely has its problems, but I am guessing that run-time surprises regarding formatting specifiers mismatching the arguments passed are rarer. There are still (probably) pitfalls lurking in constructing format specifiers with user input, as % signs can be either data or their magic meaning, I wonder if Java somehow catches those--they make for very tricky bugs because they are data-dependent, avoiding them involves ensuring % signs meant literally get doubled to %% before being used as part of a format string. Maybe that can't affect Java, but it can wreak havoc in C/C++ for sure.

jvsnyc
Автор

This is not java though... this is c programming. In the real basics of java this techniek (at least the part with %.2f) doesn't seem to work. It just prints %.2f%n for as far as i can see. Besides, putting in the comma-sign behind the quote-signs gives an error straight away. Up top in the screen you can even see you're not using standart Java-code but C....

alwingerrits