Page 1 of 1
Type value for constants or something to fix this
Posted: Wed Jan 11, 2006 11:12 pm
by Psychophanta
Returns wrong.
Returns good, but it is ugly to say the compiler a constant is float by adding .0 to the value.
Posted: Thu Jan 12, 2006 5:56 pm
by remi_meier
It isn't a problem for me, but 256f would be shorter (and 256d for doubles

)
Posted: Thu Jan 12, 2006 5:58 pm
by Polo
#a.f would just be perfect

Posted: Thu Jan 12, 2006 6:10 pm
by remi_meier
But a constant cannot have a type because the 'preprocessor' just inserts
it directly to the code. It would break some 'standard'

(but it would
be ok for me

)
Posted: Thu Jan 12, 2006 6:22 pm
by Kale
Polo wrote:#a.f would just be perfect

This is how it used to be but was changed, it was just wrong.
I think this is ok, just add a '.0' if you want the compiler to use floats.
Posted: Thu Jan 12, 2006 6:50 pm
by Psychophanta
Kale wrote:I think this is ok, just add a '.0' if you want the compiler to use floats.
It is ok, and functional, but ugly, not very elegant
I think there must be better solution.

Posted: Thu Jan 12, 2006 11:46 pm
by Rescator
Not really, as a constant is just a constant that is glued in as is into a line of code.
So if you have to use .0 in the code line then you also need to use .0 in the constant.
Posted: Tue Jan 17, 2006 6:02 pm
by Psychophanta
Do you see what i want to say? Is it consistent?
EDIT: Well, i've said nothing but repeat ... forget
Posted: Tue Jan 17, 2006 8:47 pm
by blueznl
psycho, yes, it is consistent, and you know

Posted: Tue Jan 17, 2006 11:46 pm
by Rescator
It would really confuse beginners, as you would have so many variations.
#a.f=256 ;integer forced to float
#a=256.0 ;float
#a.f=256.0 ;float float?
#a=256 ;integer
I don't know about you folks but I find having just
#a=256.0 ;float
#a=256 ;integer
so much simpler
I've made it a habit to always use .0 on "round" floats.
Posted: Mon Mar 03, 2008 2:35 pm
by #NULL
<edit>
stupid code removed :roll:

Posted: Mon Mar 03, 2008 3:47 pm
by Kaeru Gaman
Debug wrote:0.0
*puzzled*
...so, who said it did right?
...mind the typecast order in PB.
it's always an issue, so you should be used to it meanwhile...
Posted: Mon Mar 03, 2008 8:07 pm
by Psychophanta
Kaeru Gaman wrote:
Debug wrote:0.0
*puzzled*
...so, who said it did right?
I did. It worked for previous versions.
Now you need to do:

Posted: Mon Mar 03, 2008 8:38 pm
by Kaeru Gaman
yup, but it's still a typecast-problem.
like this one:
http://www.purebasic.fr/english/viewtopic.php?p=202206
but I think, especially for constants it should be no problem to write it in a way that will work, e.g.
PS:
I agree that it would be nice to type constants, but this will be no solution for this problem.
will produce the same problem, because 1 and 3 are integer and result in 0