Is there a simple way to truncate?
I'm using a pot.
I want to divide its value by 100 and toss out the decimal.
so its value would be something between 0 and 10.
doesn't have to be precise.
I just need the value without decimals.
int pinVal = analogRead(pin);
int onePercent = pinVal / 100;
onePercent will be a value between 0 and 10.
isnt a pot a 0-1023 value?
if, say I divide 1023 by 100 i would get 10.23
forgive me if im being dim!
i suppose i could write a bunch of if statements.
but i would like to know how to truncate if theres a way to do it.
there must be a way
if, say I divide 1023 by 100 i would get 10.23
But "int" is an integer data type.
I appreciate your replies.
ok, so if i declare as an int, means decimals will be dropped/ignored?
Dropped. Truncated.
You can write
int x = 10.7;
but the value of x will be 10. It will not round.
awesome, thank you for the help.
I appreciate it!