PDA

View Full Version : floating point numbers



n qwerty
- 4th April 2008, 23:13
i need to get a floating point numbers for a speed measurement to ensure accuarcy. Currently i have metres/hundreth which needs to be converted into mph. therefore i need a float number which pbp cant handle. any ideas would be greatfully appreciated.

mister_e
- 4th April 2008, 23:27
no you NEVER EVER need ANY float, and YOU DON'T want to use ANY float anyway.

I already heard..."huh using float.. what's the point?" and i really laugh... "point" in french is dot... so translate it the way you want, you should understand what i mean ;) Simple multiplication by 100, 100 or 10000 will solve most see all problem.. the dot is just visual effect ;) you can override it easy using DEG, DIG and whatever else if you really need to DISPLAY it

Float point routine are just slow and code hungry for nothing... forget about it.

<hr>
http://en.wikipedia.org/wiki/Floating_point
http://www.cs.princeton.edu/introcs/91float/

<hr>
What's your actual value range you need to change to mph?

Which version of PBP do you have?

Acetronics2
- 5th April 2008, 10:02
Hi, Steve

NO FP needed ...

1 Mile = 1619/1006 Km w. Zero error
1 Mile = 758 / 471 Km w. 1.35 ppm error
1 Mile = 103 / 64 Km w. 19.3 ppm error

my favourite :

Km = Mile */ 412

Best of ALL

RTFM , last edition, $ 4.17.1 p.35 ...

" if you wish to convert miles to kilometers ... etc,etc ..."

Alain

PS: What about THAT ???

http://www.miscel.dk/MiscEl/miscelIntegerMath.html

http://www.miscel.dk/MiscEl/miscel.html

Just to be downloaded ... no ???

n qwerty
- 6th April 2008, 12:52
for example if i want to do a calculation 80/2.74 = 29.1971

how would i go about doing this to get the 29.1971 value. i could times up the 80 by 100 but i cant go above 65535 since that is the size of a word. Any ideas on how to get the value of 29.197 so i can times it by a conversion rate?

n qwerty
- 6th April 2008, 20:33
if i do

x = 2560/153

x should = 16.73..... but pbp will see it as 16. therefore i wanted to use the remainder function to get the 0.7


remainder = 2560 // 153

but when i print it out on an lcd it says that the remainder is 0. Why is 7 not stored ?


Thanks

mister_e
- 6th April 2008, 22:26
I see some several ways... which PBP version, which PIC?

n qwerty
- 7th April 2008, 17:15
its a pic16f77

pbp version 2.3.0.0 and

mplab ide v7.60

many thanks

Acetronics2
- 7th April 2008, 17:41
V2.30 with 16F77 ...

might provide interesting moments ...

Alain

skimask
- 7th April 2008, 18:15
V2.30 with 16F77 ...
might provide interesting moments ...
PBP 2.50a upgrade....only $25....

How much says the O/P can't get it?

mister_e
- 7th April 2008, 18:40
Well Alain is right this device is not supported in this version... pretty old one i have to say :o

Really worth to upgrade everything you have on hand.

MPLAB is free and now V8.xx
PBP: now V2.50

Jerson
- 8th April 2008, 04:18
PS: What about THAT ???

http://www.miscel.dk/MiscEl/miscelIntegerMath.html

http://www.miscel.dk/MiscEl/miscel.html

Just to be downloaded ... no ???

Alain

Thank you very much for pointing to this very useful utility.

Jerson