• Welcome, Guest. Please login.
 
October 19, 2021, 12:16:00 AM

News:

Welcome to the SQLitening support forums!


Got problem with % (Mod) operator in SQLite

Started by jayantkashelikar, February 24, 2015, 01:06:09 PM

Previous topic - Next topic

jayantkashelikar

I am using SQLite on Windows machine in a desktop application where i stumped on this issue.

I have a table where "$ANGLE" is the Column having datatype as REAL table name is : "TEST:POINT"

values stored in are as follows:






$ANGLE
"100.561027526855"
"123.617576599121"
"213.293853759766"


whenever i try to do a select query as
SELECT ("$ANGLE" + 90) %360 as ANGLE FROM "TEST:POINT"

it returns me result as follows






ANGLE
"190.0"
"213.0"
"303.0"
where as I expected result should look as follows:






ANGLE
"190.561027526855"
"213.617576599121"
"303.293853759766"

Your help/expertise is much appreciated.
Thanks in advance.

jayantkashelikar

Just now i changed my select query and got the expected result.
the modified query is as follows:

SELECT ("$ANGLE"+90.0)-(360.0 * (CAST("$ANGLE"+90 as integer)/360)) FROM "TEST:POINT"

logical reason behind this is very simple

% operator always treat both operands as integer and returns a value based on integer values (no decimal points at all)

recording this solution here so that someone trying to find the solution similar to my situation will get help