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.
228
Upvotes
56
u/MisterHandy Sep 11 '18
You're welcome. ;)
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.
💯
30
u/kiipa Sep 11 '18
The correct way is
To get a single, you'd quite naturally do
Hope this helps!
20
u/Camto Sep 11 '18
Sorry I can't help,
single value;doesn't even work for me.17
u/Botteknotten Sep 11 '18
Try
double + (double/2) value;?9
u/Bill_Morgan Sep 11 '18 edited Sep 13 '18
I usually do this:
4
u/myhf Sep 12 '18
3
u/[deleted] Sep 12 '18
3
u/[deleted] 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.
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
u/Cenotaph2000 Nov 05 '18
Value = Value + (Value/2) Basic arithmetic to the rescue yet again.
4
u/2omesz Sep 12 '18
since this is r/shittyprogramming then the best way is:
value = value + value + value;
thank me later.