-
Mar 12th, 2017, 10:15 PM
#1
Thread Starter
Lively Member
Turning an integer or decimal number into a decimal in the tenths, hundredths, etc...
Hello! I am developing a program to help me do some stuff that isn't important. Anyways, I need a way to make say the number 5 into 0.5 or 05 into 0.05 or 5.31 into 0.531 | I have no idea how to do this. I am new to the language and learning everyway possible, all suggestions would be fantastic! Thanks!!!
-
Mar 12th, 2017, 10:25 PM
#2
Re: Turning an integer or decimal number into a decimal in the tenths, hundredths, et
That's not really a consistent requirement. You treat "5" and "05" differently, so how would you treat "05.31"?
Anyway, I don't think you've really given this much thought. It's basically turning a String into number and performing a division, both of which are quite elementary operations.
-
Mar 12th, 2017, 11:17 PM
#3
Thread Starter
Lively Member
Re: Turning an integer or decimal number into a decimal in the tenths, hundredths, et
I know how to, I was hoping there would have been a way to do it exactly the way I want it to. I guess I can make a work around, I was just hoping it would simply detect it and convert it to 0.{number here}
-
Mar 12th, 2017, 11:30 PM
#4
Re: Turning an integer or decimal number into a decimal in the tenths, hundredths, et
As I said, it's not a consistent requirement. If it was just integers then you could simply prepend "0." to the digits you have and then convert that to a Double but that's obviously not going to work for numbers that already have a decimal point. If you want to do different things based on certain criteria then you have to use an 'If' statement or the like. There's no single operator that will read your mind on this.
-
Mar 12th, 2017, 11:45 PM
#5
Thread Starter
Lively Member
Re: Turning an integer or decimal number into a decimal in the tenths, hundredths, et
I guess so haha, well thanks anyways man
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|