r/shittyprogramming • u/Intrexa • Sep 11 '18
How to triple a value?
Hi guys, I'm having a problem where I need to triple a value. I know I can double something like this:
double value;but if I try
triple value;I get an error. Please help. This homework is due in 3 minutes.
114
u/Rezmason Sep 11 '18
A double is twice the length of a float. So to get a triple just add a float and a double.
💯
47
u/GRAIN_DIV_20 Sep 12 '18
Be careful with this because if the number is too big it will be too heavy to float
6
u/northrupthebandgeek Sep 12 '18
You have it the wrong way around. If the number gets bigger without getting heavier, it'll actually have an easier time being a float.
30
u/kiipa Sep 11 '18
The correct way is
long double x;To get a single, you'd quite naturally do
short double x;Hope this helps!
0
20
17
9
u/Bill_Morgan Sep 11 '18 edited Sep 13 '18
I usually do this:
value << 1.5;5
4
3
3
Sep 14 '18
You don't need to declare value as a triple. This solution works perfectly and you can tell it's efficient because I used value++ instead of something retarded like value += 1.
double value;
while(value < 3*value){
value++;
}2
u/Never-asked-for-this Sep 11 '18
You need to do double + value, since value is only one and double is double.
2
4
u/2omesz Sep 12 '18
since this is r/shittyprogramming then the best way is:
value = value + value + value;
thank me later.
6
Sep 12 '18
that would actually work. the purpose of this sub is taking everything literally. he has
doublealready, now he needstriplehang out here some more and you'll get the hang of it :)
56
u/MisterHandy Sep 11 '18
You're welcome. ;)