Skip to content

Instantly share code, notes, and snippets.

@kalaiselvan369
Created June 8, 2023 11:12
Show Gist options
  • Save kalaiselvan369/aaae2004363965f1342741bf32a65970 to your computer and use it in GitHub Desktop.
Save kalaiselvan369/aaae2004363965f1342741bf32a65970 to your computer and use it in GitHub Desktop.
Various notation in double, float and literal constants
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