AngleGadget - circular trackbar + user-defined labels

Share your advanced PureBasic knowledge/code with the community.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: AngleGadget - circular trackbar + user-defined labels

Post by netmaestro »

@skywalk: That has nothing to do with the float assignment. You're testing the (continually incrementing) count var against itself multiplied by 2. It should go on forever, if it didn't that would be a concern.
BERESHEIT
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: AngleGadget - circular trackbar + user-defined labels

Post by luis »

@netmaestro

OMG. I just checked the 4.20 (one of the first versions I used).

You are right, the decimal part was cut off at the time ! This can be a major cause of old sources going to hell.

It's not like a library command modified, it's the core of the language.

I don't feel very well ....


output of PB 4.20 for reference:

Code: Select all

l.i = 0.6 * 2
Debug l ; 1 (1.2 rounded down, apparently) - in reality cut off

l.i = 0.9 * 2
Debug l ; 1 (cut off)

l.i = 0.6
Debug l*2 ; 0 (make sense)
When all this changed ? And most importantly, can we count to have this behavior back again ?
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: AngleGadget - circular trackbar + user-defined labels

Post by netmaestro »

Fred should change it back, that's my opinion.

c:

Code: Select all

#include <stdio.h>

int main()
{
	float a = 0.99;
	int b = 0;
	b=a;
 	printf( "Float 0.9 assigned to int 0 = %d", b );  /* displays 0, the whole decimal portion is chopped */

	getchar();
}
Last edited by netmaestro on Mon Jul 11, 2011 4:29 pm, edited 1 time in total.
BERESHEIT
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: AngleGadget - circular trackbar + user-defined labels

Post by rsts »

luis wrote: snip

When all this changed ? And most importantly, can we count to have this behavior back again ?
Are you asking that it be changed back?

If so, anyone counting on the more recent behavior would be in trouble.

cheers
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: AngleGadget - circular trackbar + user-defined labels

Post by luis »

rsts wrote: If so, anyone counting on the more recent behavior would be in trouble.
Exactly so.

And I reiterate that ALL this should be written down, it's really silly to have to experiment to see when a implicit cast is performed and how (round up, round down, cut off, etc.). Same thing for what's happening inside a mixed expression, and moreover on different architectures (x86/x64) if there are differences (and the code in this thread just shown there are plenty).
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: AngleGadget - circular trackbar + user-defined labels

Post by netmaestro »

I can find no mention of this in the history page. That is a concern as it seems completely undocumented.
BERESHEIT
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: AngleGadget - circular trackbar + user-defined labels

Post by luis »

What I mean is, instead of adding a new 3d command it's a lot more important to define and document the basic behavior of the language to help the initial understanding from new users and avoid further "drifting" like this in the future for old ones.

For example, I'm certainly dumb, and I didn't notice this was changed. I simply thought, "oh look, pb does it that way? I thought was the same way of C, well ok". Instead netmaestro remembered something different (thanks to him!).

If all this was clearly defined I would have checked the language definition like I would do for C, C++ or whatever.

OK a little experiment and hacking, Fred & Co are not an armada of software developers, with a branch dedicated to documentation and so on, they are great and I respect them, but some perspective on what it's really important is required.

At least that's my very personal opinion. Hope this can be taken as benign criticism.


EDIT in 2020: Wow, reading this today I find incredible how naive I was just 9 years ago.
Last edited by luis on Fri Aug 14, 2020 8:08 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
skywalk
Addict
Addict
Posts: 3999
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: AngleGadget - circular trackbar + user-defined labels

Post by skywalk »

netmaestro wrote:@skywalk: That has nothing to do with the float assignment. You're testing the (continually incrementing) count var against itself multiplied by 2. It should go on forever, if it didn't that would be a concern.
:oops: brain fart.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
idle
Always Here
Always Here
Posts: 5096
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: AngleGadget - circular trackbar + user-defined labels

Post by idle »

despite the casting bugs , that's a one nice control thanks Stargate
Windows 11, Manjaro, Raspberry Pi OS
Image
SiggeSvahn
User
User
Posts: 40
Joined: Wed Oct 06, 2010 9:37 pm

Re: AngleGadget - circular trackbar + user-defined labels

Post by SiggeSvahn »

Is working fine if replacing the deprecated #PB_Canvas_GrabMouse with #PB_Canvas_Cursor. Thanks!
Newbie
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: AngleGadget - circular trackbar + user-defined labels

Post by Kwai chang caine »

Apparently, i not see this code in 2011 :oops:
So a "little bit" thanks at Stargate for sharing it 8)
ImageThe happiness is a road...
Not a destination
Post Reply