Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Game Design Theory / How to convert 0.5 to 2, 0.25 to 4, 0.125 to 8, etc.?

Author
Message
Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 11th Jan 2013 01:09
Hey all,

I really had no idea where to post this, so I'm posting it here.

I need a way of "resizing" a value between 0 and 1 to a number between 1 and infinity. I'm not a maths expert, but I've thought about this for many hours and still can't come up with a solution.

When the original value = 1, I need the new value to be 1 also.
When original = 0.75, new must = 1.5.
When original = 0.5, new must = 2.
When original = 0.25, new must = 4.
When original = 0.125, new must = 8.

The function or method must support any floating point value between 0 and 1. It must convert the value to a floating point value that is larger and larger as the original value approaches 0. The function need not handle an input of 0, because the value I input will never be 0.

It's a lot to ask, I know, but I have no idea how to do this. I'm sure there is a way of doing this.

Thanks,
Clonkex

Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 02:17 Edited at: 11th Jan 2013 02:17
In general, it would be 1/the number.

1/0.75=1.33333333333
1/0.5=2
1/0.25=4
1/0.125=8
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jan 2013 02:31
Nicely done Fluffy Rabbit

Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 02:35
@MrValentine-

Thanks. Was this some kind of elaborate joke or something? I mean, I'm really terrible at math, but this was really obvious. Ten seconds worth of thought.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jan 2013 03:54
It was a genuine comment

I came to realise about 10 years too late that I was actually not doing too bad in high school at Maths, [Group 4 out of 10 for four years in a row, where group 10 is the weakest and group 1 is the smartest, group 1 and 2 was too full so broken across group 1 and 2, making me technically group 3] aside from practically NEVER doing my home work...

I loved percentages, probability and Statistical Analysis... Everything else I practically sucked at... but hey I got the bases

But simple things are often overlooked... I try as much as possible to keep things simple, even so... you can manage to overlook them...

Thank you for pointing it out

Fluffy Rabbit
User Banned
Posted: 11th Jan 2013 04:28
I'm just saying that whoever would ask such a simple question after supposedly spending hours of work looking for the answer clearly has no idea what he's talking about and shouldn't be programming.
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jan 2013 05:55
aaaa that is a bit too much salt Fluffy...

As I said before... we often forget or overlook the simple things...

Clonkex
Forum Vice President
13
Years of Service
User Offline
Joined: 20th May 2010
Location: Northern Tablelands, NSW, Australia
Posted: 11th Jan 2013 06:39
*facedesk facedesk facedesk*

Ah DAMMIT I KNEW there was a simple answer!!

And it's soooooo simple I am extremely embarrassed that I wasn't able to see it myself.

It's just....wow that's so simple...how could I NOT see that?!

Wait- I know why I didn't see it: it was too simple. I'd been looking for a much more complicated method of doing this.

Fluffy Rabbit:

Please believe me when I say I'm actually a very good programmer and am fairly good at maths.

You know how you can be staring at a problem on the computer or in some puzzle game when someone walks up behind you, looks over your shoulder and within 2 seconds tells you the answer? Well, that's what it feels like for me right now.

But thanks for the answer anyway.

*facedesk* I can't believe I failed this so badly...

MrValentine:

Thanks for defending me

Clonkex

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jan 2013 07:03
Anytime Clonkex, Anytime...

Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 14th Jan 2013 22:31 Edited at: 14th Jan 2013 22:32
Quote: "I'm just saying that whoever would ask such a simple question after supposedly spending hours of work looking for the answer clearly has no idea what he's talking about and shouldn't be programming."

What's with the attitude on every post you make? Are you constantly angry?

Shh... you're pretty.
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 19th Jan 2013 11:42
This site will do wonders for brushing up on your elementary maths skills.

http://www.khanacademy.org/

It's sure helped me out!

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 19th Jan 2013 11:52
Quote: "What's with the attitude on every post you make? Are you constantly angry?"

Well, I mean, it is kind of a huge brain fart. Like, a question for which an understandable answer would be, "Are you alright?"

b][/b]p

(Not putting down! I do it too sometimes)

(...but, I mean, I'd have assumed you knew that, so I could definitely see how Fluffy Rabbit could make a comment like that, considering in all likelihood it didn't apply to you. but. well. it did... 8D)

Login to post a reply

Server time is: 2024-04-23 17:26:39
Your offset time is: 2024-04-23 17:26:39