By default all number defined are Decimal (to the base 10).
Example : 10, -120.30, 0 , 110393 , 4/3
Binary numbers have a base 2.To denote a number as a binary Number it has to be prefixed with 0b
Example : 0b1010, 0b10, 0b10101
Octal numbers have a base 8.To denote a number as a Octal Number it has to be prefixed with 0o
Hexadecimal numbers have a base 16.To denote a number as a Hexadecimal Number it has to be prefixed with 0x
// Swift Tutorials 2014-15
// Boolean in Swift
// Created by Code2care on 15/09/14.
// Copyright (c) 2014 Code2care. All rights reserved.
var myDecimal = 20;
var myBinaryNumber = 0b101010;
var myOctalNumber = 0o17;
var myHexaDecimalNumber = 0xFFA;
//Note that the output will be converted to decimal numbers
Program ended with exit code: 0