Created
June 8, 2023 11:12
-
-
Save kalaiselvan369/aaae2004363965f1342741bf32a65970 to your computer and use it in GitHub Desktop.
Various notation in double, float and literal constants
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
// double declaration | |
val d = 1.234 // type is inferred | |
val doubleNotation = 1.2e10 | |
println(doubleNotation) | |
// float declaration | |
val floatValue = 123.23452F | |
val floatValueRoundedOff = 1.234278690234f | |
println(floatValueRoundedOff) // since float has only 7 to 6 decimals, value of f is rounded to 7 decimal point | |
// declaring Int value as hex | |
val hexBytes: Int = 0xFF_FF_FF | |
println(hexBytes) | |
// declaring long value as bytes | |
val bytes: Long = 0b11010010_01101001_10010100_10010010 | |
println(bytes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment