type conversion and concatenation

How can I take 6 variables (int), v1 though v6, convert them to strings, concatenate them to v1v2v3v4v5v6, then convert to a variable (float), and divide by a variable (int).

Any problems using "long long" datatype?

I know what a long is, not familiar with a "long long". I need to use float, as I'm working with decimal places.

A 'long long' is a 64 bit integer. No, you don't need a float (32 bit) if you want to maintain precision.

I have at most, 6 digits with a decimal point (ie. 0.96765), never negative. What type would you recommend.

You can use something like:

#include <String.h>

int v1 = 1;
int v2 = 2;
int v3 = 3;
int v4 = 4;
int v5 = 5;
int v6 = 6;

String s_buffer;

void setup()
{
s_buffer =""+v1; // Most Important Int
s_buffer+=""+v2;
s_buffer+=""+v3;
s_buffer+=""+v4;
s_buffer+=""+v5;
s_buffer+=""+v6; // Less Important Int

getIntFromString(s_buffer);
}

int getIntFromString(String buffer)
{
  int i_buf = 0;
  char c_buf[buffer.length()];
  buffer.toCharArray(c_buf,buffer.length());
  
  for (int i = 0; c_buf[i]; i++)
  {
    i_buf += (10^( buffer.length()-1-i ))*(c_buf[i]-'0');
  }
  return i_buf;
}

void loop(){}

But remember max int number is 32767 !! ( unsigned int is 65535 )

F.

where is the output in this example? I don't see a variable containing the concatenated result. My max will be around 110000, before division introducing a decimal. Hence the float requirement.

getIntFromString(s_buffer);

This function return value

you can use it like:

int result = getIntFromString(s_buffer);

but using long long is better!

F.

I can't find "long long" in the reference section. How is it better than float?

#include <String.h>

int v1 = 1;
int v2 = 2;
int v3 = 3;
int v4 = 4;
int v5 = 5;
int v6 = 6;

String s_buffer;

void setup()
{
s_buffer =""+v1;
s_buffer+=""+v2;
s_buffer+=""+v3;
s_buffer+=""+v4;
s_buffer+=""+v5;
s_buffer+=""+v6;

unsigned long result = getIntFromString(s_buffer);

int divisor = 100;

float a = result / divisor;
}

unsigned long getIntFromString(String buffer)
{
  unsigned long i_buf = 0;
  char c_buf[buffer.length()];
  buffer.toCharArray(c_buf,buffer.length());
  
  for (int i = 0; c_buf[i]; i++)
  {
    i_buf += 10^(i+1)*(c_buf[i]-'0');
  }
  return i_buf;
}

void loop(){

}

Way better than float. 64 bit vs. 32 bit.

I could not find

#include <String.h>

I get the result:

080090 5 1

from:

int v1 = 1;
int v2 = 2;
int v3 = 3;
int v4 = 4;
int v5 = 5;
int v6 = 6;

String s_buffer;



void setup()
{
  
Serial.begin(19200);

s_buffer =""+v1; // Most Important Int
s_buffer+=""+v2;
s_buffer+=""+v3;
s_buffer+=""+v4;
s_buffer+=""+v5;
s_buffer+=""+v6; // Less Important Int

getIntFromString(s_buffer);
}

int getIntFromString(String buffer)
{
  int i_buf = 0;
  char c_buf[buffer.length()];
  buffer.toCharArray(c_buf,buffer.length());
  
  for (int i = 0; c_buf[i]; i++)
  {
    i_buf += (10^( buffer.length()-1-i ))*(c_buf[i]-'0');
  }
  return i_buf;

int result  = getIntFromString(s_buffer);

  Serial.print(result);
}


void loop(){



}

Why do I need 64 bits? 32 seems big enough, and Long Long seems to be an int, so how can it handle decimal places?

If 32 bits is sufficient, why bother with float?

decimal places. 0.80090 does not fit the int or long data type, correct?

I get the result:

42949668.00 (I was expecting 234.56)

with:

int v1 = 1;
int v2 = 2;
int v3 = 3;
int v4 = 4;
int v5 = 5;
int v6 = 6;

String s_buffer;

void setup()
{
  
  Serial.begin(19200);
  
s_buffer =""+v1;
s_buffer+=""+v2;
s_buffer+=""+v3;
s_buffer+=""+v4;
s_buffer+=""+v5;
s_buffer+=""+v6;

unsigned long result = getIntFromString(s_buffer);

int divisor = 100;

float a = result / divisor;

Serial.print (a);

}

unsigned long getIntFromString(String buffer)
{
  unsigned long i_buf = 0;
  char c_buf[buffer.length()];
  buffer.toCharArray(c_buf,buffer.length());
  
  for (int i = 0; c_buf[i]; i++)
  {
    i_buf += 10^(i+1)*(c_buf[i]-'0');
  }
  return i_buf;
}

void loop(){

}

Depends where you put the decimal point. ;)

What does the value represent? Does dividing 80090 by 100000 make sense?

Jumping in asking how to do something, and then not answering all the questions asked is a bit rude.

The reason for the questions is to help determine if there is a better way to accomplish your goal.

I gave the position of the decimal point in the example.

In inches mode, it looks like 0.80090 in mm mode it looks like 20.343

"It looks like" and "it is" are not the same thing. Do you think your micrometer works in floating point? Does it supply results in floating point?