Numerical optimizer

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
coderJeff
Site Admin
Posts: 3093
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Numerical optimizer

Postby coderJeff » Feb 20, 2019 10:31

hey sean_vn, could you please add an explanation to your first post? You can edit your own posts. deltarho's and jj2007's first posts look like constructive feed back to me. Thanks.
Lost Zergling
Posts: 242
Joined: Dec 02, 2011 22:51
Location: France

Re: Numerical optimizer

Postby Lost Zergling » Feb 20, 2019 11:48

@sean_vn " This forum got very unfriendly very quick." : I share this opinion, and so we are less bored. Do like me, be a Zergling, and everything will be fine. I have a hard time explaining things that seem simple to me when I'm in my ideas and in my code. Because I am in my context and even if this context is obvious to me, it requires a consequent effort to others, even on simple things, and it is the same for each of us. Thus, the restitution of contextual elements is also a question of respect towards others, which may explain reactions all legitimate.
dodicat
Posts: 5944
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Numerical optimizer

Postby dodicat » Feb 20, 2019 11:51

sancho3 wrote:Here is the post that has been alluded to.
Since you have been away, you should know that there has been tension in forums. Enough so that a moderator has been brought on to aid in administering the forum. Here is that forum topic.
I have to admit that the first thing I thought when I saw the title was "what is this code about?". And then disappointment when it was code with no explanation.
I am not the moderator nor am I chastising. I recommend that you can avoid the tension by one or two lines explaining at least what the code is doing.
And then posting "Tested on 32bits only". This makes your post more "friendly".


Actually the 32 bit compiler faults.
I put the faulting bit up again

Code: Select all

 var n= &hffffffff
var m= 4294967295
print n
print m
#print typeof(n)
#print typeof(m)
sleep
   

I cannot yet test the new fb1.06 with this, I keep getting antivirus errors on GoRC.exe, but I am still working on it.
Anyway, why should the above snippet fail on 32 bits? (gives a -1 for n)
srvaldez
Posts: 2111
Joined: Sep 25, 2005 21:54

Re: Numerical optimizer

Postby srvaldez » Feb 20, 2019 12:53

perhaps you should add type suffix to the constants
deltarho[1859]
Posts: 2003
Joined: Jan 02, 2017 0:34
Location: UK

Re: Numerical optimizer

Postby deltarho[1859] » Feb 20, 2019 13:18

I have never got to grips with 'var' resulting in unpredictability so I never use it. If I remember correctly fxm does not use it either.

I would rather 'Dim As Ulong n = &hffffffff, m = 4294967295

Having said that srvaldez's suggestion works.
var n = &hfffffffful
var m = 4294967295ul

I have also found TypeOf to be a bit 'flaky' as well. Example 2: in the Help manual does not print anything.

I should add that I am using FBC 1.06 now.

@dodicat

You are not the only one getting antivirus errors on GoRC.exe. The best antivirus software a few years ago are now falling by the wayside. Having said that I have been using ESET for a few years without any issues and it is still in the top rankings.
MrSwiss
Posts: 3266
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Numerical optimizer

Postby MrSwiss » Feb 20, 2019 13:40

@dodicat,

your GoRC.exe problem is already solved ... see: Building FB 1.06 Release thread.
dodicat
Posts: 5944
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Numerical optimizer

Postby dodicat » Feb 20, 2019 14:43

Thanks Mr Swiss.
Deltarho, If you use the winfbx ide and you won't see the result of #print.
Perhaps there is an option to correct this, but I can't find it.
On fbide the results of #print show in the messages window.
deltarho[1859]
Posts: 2003
Joined: Jan 02, 2017 0:34
Location: UK

Re: Numerical optimizer

Postby deltarho[1859] » Feb 20, 2019 15:13

dodicat wrote:Perhaps there is an option to correct this, but I can't find it.

I think that I have been here before but my memory is letting me down. #print is put into the compiler log file. In WinFBE the fastest way to get to that is via Ctrl F9. I hate accelerator keys, I can never remember them for all of the applications that I have installed. I am a mouse man and prefer drop down menus any day of the week.

Thanks for jogging my memory.
fxm
Posts: 9185
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Numerical optimizer

Postby fxm » Feb 20, 2019 15:14

It would be nice if all IDEs also output the preprocessor texts (for example #print ...) inside the compiler result window (as for the compiler errors/warnings).
For example, it's true for FBIde but not for WinFBE.
Last edited by fxm on Feb 20, 2019 16:05, edited 1 time in total.
fxm
Posts: 9185
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Numerical optimizer

Postby fxm » Feb 20, 2019 15:20

deltarho[1859] wrote:In WinFBE the fastest way to get to that is via Ctrl F9.

Or click on the right side of the status bar.
deltarho[1859]
Posts: 2003
Joined: Jan 02, 2017 0:34
Location: UK

Re: Numerical optimizer

Postby deltarho[1859] » Feb 20, 2019 15:29

@dodicat

BTW

var n= &hffffffff has TypeOf giving Integer, which is signed, and why we get -1.

var m = 4294967295 has TypeOf giving Uinteger.

srvaldez's suffix suggestion is one way to but we have to remember to force the issue. Dim is KISS and does what it says on the box.

fxm wrote:Or click on the right side of the status bar.

My mouse sends you its best wishes, as I do. Thanks

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 48 guests