Reputation: 1512
I am new to Swift, and am stuck on a little problem. I have the current hour and minute(s) as Ints, and would like to know how to put them together, to create one whole number, like military times. WITHOUT CONVERTING TO STRING, as I need to be able to compare ( using < and >) later on.
EXAMPLE:
Upvotes: 0
Views: 1124
Reputation: 150615
Multiply the current hour by 100 then add the number of minutes. From your example:
02 * 100 = 200
200 + 24 = 224
Upvotes: 2
Reputation: 3433
Here is a simple example
var num:Int = 02
print(num)
var num2:Int = 24
Double.init("\(num)\(num2)")
Upvotes: 0