Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:45 29 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite Math. Problem ?

Author Message
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 07:29am 16 Apr 2014
Copy link to clipboard 
Print this post

Hello Friends!

I have a little math. problem with Micromite Beta 18, also in Beta 15!


NEW
> AUTOSAVE
a = 1.0
b = 0
x = 0
PRINT ""
FOR s=0 TO 9
a = a - 0.1
b = b + 0.1
PRINT "A:"a" B:"b
NEXT s

PRINT ""
a = 6.6
FOR s=0 TO 30
a = a - 0.3
PRINT "A:"a" S:"s
NEXT s

PRINT ""
a = 1.0
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
a = a - 0.1
PRINT "A:"a
Saved 385 Bytes

THE RESULT

> RUN

A: 0.9 B: 0.1
A: 0.8 B: 0.2
A: 0.7 B: 0.3
A: 0.6 B: 0.4
A: 0.5 B: 0.5
A: 0.4 B: 0.6
A: 0.3 B: 0.7
A: 0.2 B: 0.8
A: 0.0999999 B: 0.9
A:-7.45058e-08 B: 1

A: 6.3 S: 0
A: 6 S: 1
A: 5.7 S: 2
A: 5.4 S: 3
A: 5.1 S: 4
A: 4.8 S: 5
A: 4.5 S: 6
A: 4.2 S: 7
A: 3.9 S: 8
A: 3.6 S: 9
A: 3.3 S: 10
A: 3 S: 11
A: 2.7 S: 12
A: 2.4 S: 13
A: 2.1 S: 14
A: 1.8 S: 15
A: 1.5 S: 16
A: 1.2 S: 17
A: 0.899999 S: 18
A: 0.599999 S: 19
A: 0.299999 S: 20
A:-1.19209e-06 S: 21
A:-0.300001 S: 22
A:-0.600001 S: 23
A:-0.900001 S: 24
A:-1.2 S: 25
A:-1.5 S: 26
A:-1.8 S: 27
A:-2.1 S: 28
A:-2.4 S: 29
A:-2.7 S: 30

A:-7.45058e-08
>


EDIT: I have the same problem with the Maximite TFT !

What am I doing wrong or what can I do?

Thank you and best regards

Wolfgang
Edited by PicFan 2014-04-17
 
psergiu

Regular Member

Joined: 09/02/2013
Location: United States
Posts: 83
Posted: 08:08am 16 Apr 2014
Copy link to clipboard 
Print this post

It has been discussed before and it's correct. That's how the floating point maths work. Round all displayed numbers to max 4-5 decimals before displaying.

All values are correct within +- 0.000001
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3816
Posted: 08:58am 16 Apr 2014
Copy link to clipboard 
Print this post

Agreed.

John
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024