division of variables results in zero, despite values in variables divided

I have some issues. My serial monitor displays that my values used for the division are carrying number values,, yet my result is zero regardless of the changing value of the variables used. I am using this arrangement

int angularvelocity = jv / jt ;

am I missing something?? here is a paste of the few lines around it.

int jv = map (joyvelocity, 0, 1023, -255, 255);
int jt = map (joyturnangle, 0, 1023, -32000, 32000);
Serial.print (jt);
Serial.print (" ");
Serial.println (jv);
int angularvelocity = jv / jt;
Serial.println (angularvelocity);
int velocityright = angularvelocity * (jt + 5);
int velocityleft = angularvelocity * (jt - 5);

Well jt,being probably most of the time way larger than jv, and both being integers, the division (using int) of à small number by a larger one will be 0.

maybe float instead of int?

integer division will always result in 0 if abs(numerator) < abs(denominator).
one method of bare-minimum fix would be this, which forces type promotion:

float angularvelocity = ((float)jv)/jt.

I figured it out.,,

it was float,, but I had it float and it would still return zero.

jt and jv needed to be float in order for the operation to perform anytime jv was larger than jt. Actually it sounds like angular velocity CAN be int, but it will be rounded up 1, I am leaving it float for now, and in a later operation I am using angular velocity in an equation that is returning an int, and it's working fine.

Well, it's working out,, but my hardware (rc car) isn't really that well engineered (what I put together is very heavy for the motors), so you can barely get one wheel to spin faster than the other wheel under the load. it's on a 3$ caster, which isn't in the best position for the bearing of the caster to rotate,,, the caster can take over the turn of the vehicle completely. I will oil it, but you can barely feel the caster if you push with your hand,, and it completely dominates the machine when driving. Unfortunately I won't be buying good motor and chassis (that's why those mini ones are so popular,, they DO work,, well actually mine could turn in place if only one wheel spun,, travelling on a curved path, however, is hard.).

I can see the two wheels spinning differently when I hold it off the ground, but even still my H-bridge, which I put together with transistors on a breadboard, seems to also perform unevenly, where some transistors conduct much more easily, or without input. (maybe I don't know what I'm doing,, or burned them a little,, there has been some smoke associated with various power sources..,,, I need a way to regulate down a ryobi 18v,, I have tons of them and they're nearly useless at the moment.

making motors run is a lot of specialized hardware.

I did order a motor shield,, I was hoping I wouldn't want to use it,, I wonder what sort of juice it can work with,, I thought I saw some cnc machines running it?? wouldn't that take some voltage and current? I know cnc machines are well machined themselves, but still.

tsmspace:
I figured it out.,,

it was float,, but I had it float and it would still return zero.

jt and jv needed to be float in order for the operation to perform anytime jv was larger than jt. Actually it sounds like angular velocity CAN be int, but it will be rounded up 1, I am leaving it float for now, and in a later operation I am using angular velocity in an equation that is returning an int, and it's working fine.

Well, it's working out,, but my hardware (rc car) isn't really that well engineered (what I put together is very heavy for the motors), so you can barely get one wheel to spin faster than the other wheel under the load. it's on a 3$ caster, which isn't in the best position for the bearing of the caster to rotate,,, the caster can take over the turn of the vehicle completely. I will oil it, but you can barely feel the caster if you push with your hand,, and it completely dominates the machine when driving. Unfortunately I won't be buying good motor and chassis (that's why those mini ones are so popular,, they DO work,, well actually mine could turn in place if only one wheel spun,, travelling on a curved path, however, is hard.).

I can see the two wheels spinning differently when I hold it off the ground, but even still my H-bridge, which I put together with transistors on a breadboard, seems to also perform unevenly, where some transistors conduct much more easily, or without input. (maybe I don't know what I'm doing,, or burned them a little,, there has been some smoke associated with various power sources..,,, I need a way to regulate down a ryobi 18v,, I have tons of them and they're nearly useless at the moment.

making motors run is a lot of specialized hardware.

I did order a motor shield,, I was hoping I wouldn't want to use it,, I wonder what sort of juice it can work with,, I thought I saw some cnc machines running it?? wouldn't that take some voltage and current? I know cnc machines are well machined themselves, but still.

If you use floats, all need to be float.

int jv = map (joyvelocity, 0, 1023, -255, 255);
int jt = map (joyturnangle, 0, 1023, -32000, 32000);

Not floats!

Paul