Basic math errors issue

Discuss the Firewing language

Basic math errors issue

Postby Timbo » Wed May 13, 2015 9:57 am

Hi,

Doing some maths I started to get odd results

I'm compiling for the firewing18 board

Code: Select all
 COnst ValueA = 3000000
 Dim ValueUshort as Ushort  = 3075
// Dim ValueUlong as ULong
 Dim ResultUshort as Ushort
 Dim ResultUlong as Ulong

' Declarations...

Sub Main()

ResultUshort = ValueA / ValueUshort
ResultUlong = ValueA / ValueUshort


End Sub


At the end for the same sum I get
ResultUshort = 16
ResultUlong = 975

For info I'm looking at the results in a VSM (ISIS)

Any ideas where its all going wrong?
Timbo
 
Posts: 93
Joined: Fri May 03, 2013 7:51 pm

Re: Basic math errors issue

Postby Timbo » Wed May 13, 2015 12:29 pm

ok i found my issue

By using a Ushort for the ValueUshort and a Ushort for ResultUshort I forced the compiler to use Word maths. Using ResultULong or changing ValueUshort to be a Long it forces it to DoubleWord maths

Using word maths causes the compiler to mess the very log constant.

I know now how to solve my issues.

Thanks Tim
Timbo
 
Posts: 93
Joined: Fri May 03, 2013 7:51 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 3 guests

cron

x