convert double to Integer?????????
-
Hi there How to convert double to int? Q1: if a double is smaller than 1.4, it will be assign to 1 Ex: 1.3 will be 1 if a double is bigger than 1.4, it will be assign to 2 Ex: 1.5 will be 2 Q2: if a double is bigger than 1 and smaller than 2, it will be assign to 2 Ex: 1.20 will be 2 2.10 will be 3 Does anyone know the function? Thanks.
-
Hi there How to convert double to int? Q1: if a double is smaller than 1.4, it will be assign to 1 Ex: 1.3 will be 1 if a double is bigger than 1.4, it will be assign to 2 Ex: 1.5 will be 2 Q2: if a double is bigger than 1 and smaller than 2, it will be assign to 2 Ex: 1.20 will be 2 2.10 will be 3 Does anyone know the function? Thanks.
Can't u use a cast? The word of the day is legs, let's go back to my house and spread the word ;P
-
Hi there How to convert double to int? Q1: if a double is smaller than 1.4, it will be assign to 1 Ex: 1.3 will be 1 if a double is bigger than 1.4, it will be assign to 2 Ex: 1.5 will be 2 Q2: if a double is bigger than 1 and smaller than 2, it will be assign to 2 Ex: 1.20 will be 2 2.10 will be 3 Does anyone know the function? Thanks.
Q1: Add 0.5 and cast to int. Q2: (rounding up) is done bey ceil() (and ronding down by floor()).
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.