double type

Discuss the Firewing language

double type

Postby Jerry Messina » Sun Dec 08, 2013 2:01 pm

Thanks for adding support for 64-bit floats!

Are there plans for adding/changing the functions in math and convert to support the new type too?
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: double type

Postby David John Barker » Sun Dec 08, 2013 2:38 pm

Time permitting I would like to do that. For the time being though, you can pass a double to the math routines but note the parameter and result will be scaled to 32 bit single. If anyone can help out in this regard I would be very grateful ;-)
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: double type

Postby Jerry Messina » Mon Dec 09, 2013 2:45 pm

Is there a way to add command-line switches when building?

In order to get a 64-bit double with XC16, I had to add '-fno-short-double' to the GCC build

dim d as double = 1.23450

with -fno-short-double:
1.23450000000000
3FF3C083126E978D

without (FW/XC16 default):
1.234500050544739
3ff3c08320000000

If anyone can help out in this regard I would be very grateful

Sure, if I can figure out what the various functions in math.bas do, that is.
Most of them are probable fine using floats.
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: double type

Postby Jerry Messina » Mon Dec 09, 2013 3:53 pm

Also, it looks like you could squeak out a few more digits when generating the C source
Code: Select all
dim d as double

d = 1.2345678901234560      // 0x3FF3C0CA428C59F8
d = 1.2345678901234562      // 0x3FF3C0CA428C59F9
d = 1.2345678901234564      // 0x3FF3C0CA428C59FA


generated the following (rounding the last few digits)
Code: Select all
   // d = 1.2345678901234560      // 0x3FF3C0CA428C59F8
   asm volatile("; RD_I000001_F000_000045_P000127");
   F0_F64.val = 1.23456789012346;
   // d = 1.2345678901234562      // 0x3FF3C0CA428C59F9
   asm volatile("; RD_I000002_F000_000046_P000127");
   F0_F64.val = 1.23456789012346;
   // d = 1.2345678901234564      // 0x3FF3C0CA428C59FA
   asm volatile("; RD_I000003_F000_000047_P000127");
   F0_F64.val = 1.23456789012346;
Jerry Messina
 
Posts: 280
Joined: Thu Feb 14, 2013 10:16 am

Re: double type

Postby David John Barker » Mon Dec 09, 2013 4:31 pm

I've uploaded a new BETA (B4) which should fix both of the above. Let me know how it goes. Note that the cstr() function will not have the resolution needed to display the floats accuracy but you should see the correct values in MPLAB. The float to string routine used by CStr() can be found in:

..library\sys.imports\SysProcs.bas
__strtofp()
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm

Re: double type

Postby David John Barker » Wed May 21, 2014 12:27 pm

Just a heads up, but I will be adding a "math" module in the next update for PIC16 and PIC32 that supports double. If you need it before then, just drop me an email...
User avatar
David John Barker
 
Posts: 491
Joined: Thu Nov 08, 2012 12:21 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 4 guests

x