Mr Jax
Mr Jax

Reputation: 1027

Flutter/Dart: Concatenat integers

Is it possible to concatenate integers without converting to String first?

int _test1 = 123;
int _test2 = 456;

print(int.parse(("$_test1"+"$_test2"))); // 123456

Upvotes: 2

Views: 1525

Answers (1)

laserany
laserany

Reputation: 1451

you can do it like this

void main() {
    int _test1 = 123;
    int _test2 = 456;
    int pow = 10;
    while(_test2 >= pow)
        pow *= 10;
  print(_test1 *pow + _test2);
}

source : How to concatenate two integers in C

Upvotes: 3

Related Questions