1. ## float m_fis;

I'm trying to convert an (typical) inputed value of 121115 to 12.99479 which would be (12' 11-15/16"). The values FFF-II-SS (F=feet/I=inches/S=sixteenths) is the norm in engineering dimentional input. Are there any suggestions on the best ways to tackel this.

Thanks,
Ray

2. How would you get 12.99479 out of 12' 11-15/16" on paper anyway? I can't figure it out :-)

3. ## Convert

input = 12.99479
feet = 12
inch = .99479 * 12 = 11.9375
six = .9375 * 16 = 15

12-11-15

4. Is this sufficient?
Code:
```#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main()
{
string input;

cout<<"Enter the dimensional input: ";
getline(cin, input);

int six = atoi(input.substr(input.length() - 2, 2).c_str());
int inch = atoi(input.substr(input.length() - 4, 2).c_str());
int feet = atoi(input.substr(0, input.length() - 4).c_str());

double final = (((six / 16.0) + inch) / feet) + feet;

cout<< final <<endl;
}```

5. ## hmmm

I have the input going through a GUI, defined to operate via radio button for decimal or FIS (float m_feet). Is it possiable to do this same thing without having to use the atoi? Is there a command or pointing proc. that will allow me to view a int at specific points? Or, will I have to use the itoa and then convert back.

And thank you very much for the time you have taken' to work with me on this...

6. >>Or, will I have to use the itoa and then convert back.
Breaking up an integer is a real pain, it's almost always better to convert it to a string and parse it like I did, then convert each of the parts back to integers for processing.

>> Is it possiable to do this same thing without having to use the atoi?
What you do with the input once you have it is your business, do what's most clear and easiest. What format is the input in? Is it in string, int, or floating point form when you get it? I assumed you got it as a string to begin with, that makes things way easier :-)

7. ## I tried

Not sure why this code is truncating (sorry)

I tried using what you suggested and just had unexpected results. I'm sure I'm just doing it wrong but how do I get your code to work with this:

void CRerayDlg::OnMessageButton2()
{
if (m_fis == 1) // Set to decimal
{
float worka=0;
float workb=0;
float workc=0;

UpdateData(TRUE);
worka = m_feet/2 + (m_overhang/12);
workb = (((m_feet/2) + (m_overhang/12))*m_pitch)/12;

worka = worka*worka;
workb = workb*workb;
workc = sqrt(worka+workb);

m_feet2 = workc;

m_feet2_c.EnableWindow(TRUE);
UpdateData(FALSE);
}

if (m_fis == 0) // Set to sixteenths
{

UpdateData(TRUE);

const int MAX=7;
char string[MAX];

_itoa(m_feet,string,2);

int six = atoi(string.substr(string.length() - 2, 2).c_str());
int inch = atoi(string.substr(string.length() - 4, 2).c_str());
int feet = atoi(string.substr(0, string.length() - 4).c_str());

double final = (((six / 16.0) + inch) / feet) + feet;
m_feet2=final;

MessageBox("Still Working On", "Whatever", MB_ICONEXCLAMATION);
UpdateData(FALSE);

}

}

C:\My Documents\Programming\Reray\RerayDlg.cpp(252) : error C2228: left of '.substr' must have class/struct/union type

8. Try this, I didn't know you were using C strings instead of C++ strings
Code:
```void CRerayDlg::OnMessageButton2()
{
if (m_fis == 1) // Set to decimal
{
float worka=0;
float workb=0;
float workc=0;

UpdateData(TRUE);
worka = m_feet/2 + (m_overhang/12);
workb = (((m_feet/2) + (m_overhang/12))*m_pitch)/12;

worka = worka*worka;
workb = workb*workb;
workc = sqrt(worka+workb);

m_feet2 = workc;

m_feet2_c.EnableWindow(TRUE);
UpdateData(FALSE);
}

if (m_fis == 0) // Set to sixteenths
{
UpdateData(TRUE);

char string[8]; /* +1 for nul */

sprintf(string, "%d", m_feet);

int six = atoi(&string[strlen(string) - 2]);
string[strlen(string) - 2] = '\0';
int inch = atoi(&string[strlen(string) - 2]);
string[strlen(string) - 2] = '\0';
int feet = atoi(string);

m_feet2 = (((six / 16.0) + inch) / feet) + feet;

MessageBox("Still Working On", "Whatever", MB_ICONEXCLAMATION);
UpdateData(FALSE);
}
}```
You also need to include <cstdio> or <stdio.h>, <cstring> or <string.h>, but you probably knew that. :-)

9. ## Thank You!!!

That was it!!!

Thanks...

Ray Schmidt