Use a math filter on assignment: {% assign var1 = var1 | plus: 0 %} or {% assign var2 = var2 | times: 1 %}. Either coerces the string to a number. Note that variables created with {% capture %} are always strings, so this coercion step matters before doing arithmetic.

Context: Stack Overflow question (score 59): converting a string variable to a number in Shopify Liquid templates.