|
From: Scott <fre...@ve...> - 2005-06-27 09:25:52
|
Hi peoples, Can anyone shed some light on how i achieve a minus pow value? I'm trying to place a point at -128.5=20 I'm using "pow(2,8)/2+1" Will will give me 128.5.... How do i get that to return -128.5 instead of a positive value Iv'e tried putting the - simple in various place, to no avail. Cheers, Scott. |
|
From: Masthan R. <mas...@gm...> - 2005-06-27 09:48:50
|
Hi Scott, I have worked and tried your problem. The possible solution is multiply the= =20 returned value with -1. You can write the code like this. "(pow(2,8)/2+1) * -1" which will return the negative value or the other=20 option is to use the *abs()* which does the same functionality. If u still= =20 got problem Pls reply me back. Regards Masthan On 6/27/05, Scott <fre...@ve...> wrote:=20 >=20 > Hi peoples, > Can anyone shed some light on how i achieve a minus pow value? > I'm trying to place a point at -128.5=20 > I'm using "pow(2,8)/2+1" Will will give me 128.5.... > How do i get that to return -128.5 instead of a positive value > Iv'e tried putting the - simple in various place, to no avail. > Cheers, > Scott. > =20 --=20 Regards Masthan |
|
From: Franziska E. <fra...@ya...> - 2005-06-27 09:49:09
|
Hi... try -(pow(2,8)/2+1) greetz > Hi peoples, > > Can anyone shed some light on how i achieve a minus pow value? > > I'm trying to place a point at -128.5 > > I'm using "pow(2,8)/2+1" Will will give me 128.5.... > How do i get that to return -128.5 instead of a positive value > Iv'e tried putting the - simple in various place, to no avail. > > Cheers, > Scott. > ___________________________________________________________ Gesendet von Yahoo! Mail - Jetzt mit 1GB Speicher kostenlos - Hier anmelden: http://mail.yahoo.de |
|
From: Scott <fre...@ve...> - 2005-06-27 10:08:09
|
> Hi... > try > -(pow(2,8)/2+1) > greetz Yeah doing it that way seems to be incorrect!!, It does provide the correct result if you change it to -(pow(2,8)/2-1) But thanks for the reply none the less. Marco's "(pow(2,8)/2+1) * -1" also works.. So thankyou for the replies guys. I'll also look into the ABS function as suggested. Cheers, Scott. |
|
From: Lukas 'C. M. <gry...@gm...> - 2005-06-27 11:04:15
|
I'm not sure how abs() would help.. unless that's to ensure that the original value is positive before multiplying by negative one? -Lukas On 6/27/05, Scott <fre...@ve...> wrote: > =20 > =20 > > Hi... > > try > > -(pow(2,8)/2+1) > > greetz > =20 > Yeah doing it that way seems to be incorrect!!,=20 > It does provide the correct result if you change it to -(pow(2,8)/2-1)=20 > =20 > But thanks for the reply none the less.=20 > Marco's "(pow(2,8)/2+1) * -1" also works..=20 > =20 > So thankyou for the replies guys.=20 > I'll also look into the ABS function as suggested.=20 > =20 > Cheers,=20 > Scott. |
|
From: Scott <fre...@ve...> - 2005-06-27 12:19:34
|
>I'm not sure how abs() would help.. unless that's to ensure that the
>original value is positive before multiplying by negative one?
>-Lukas
This is still not working right,
Iv'e been scratching my head on this all day..
I'm trying to get the value of 128.5
But instead all the mentioned formula's are giving me 129...
What i'm trying to express is this..
(2^8+1)/ 2 = 128.5
So in C/C++ it should be pow(2,8)/2+1 (However it returns 129)
Here is a quick test....
----------------------------------------------------------
#include <stdio.h>
#include <math.h>
void main()
{
double test;
test=pow(2,8)/2+1; //figure 2 to the eighth power +1
printf("The number is %0.0f \n",test);
system("PAUSE");
return 0;
}
-----------------------------------------------------------
#include <stdio.h>
#include <math.h>
void main()
{
float test;
test=((2^8+1) / 2); //figure 2 to the eighth power +1
printf("The number is %0.0f \n",test);
system("PAUSE");
return 0;
}
-------------------------------------------------------------
Here is a quick snippett from the actual source code i'm using to position
points.
sprintf( cmd, "MAKEBOX <%g %g %g> <%g %g %f> <%d %d %d>",
-128.5, -0.0, -128.5, pow(2,8)/2+1, 0.0, pow(2,8)/2+1, 1, 1, 1 );
local->evaluate( local->data, cmd );
Both suffer from the returning the same 129 figure....
I must be missing something stupid... (i'll try again in the morning)
Thanks for the help guys..
Cheers,
Scott.
|
|
From: Mustafa A. <Mus...@TE...> - 2005-06-27 12:40:11
|
Please try: (pow(2,8)+1)/2
Scott schrieb:
>> I'm not sure how abs() would help.. unless that's to ensure that the
>> original value is positive before multiplying by negative one?
>> -Lukas
>
>
> This is still not working right,
> Iv'e been scratching my head on this all day..
>
> I'm trying to get the value of 128.5
> But instead all the mentioned formula's are giving me 129...
>
> What i'm trying to express is this..
>
> (2^8+1)/ 2 = 128.5
>
> So in C/C++ it should be pow(2,8)/2+1 (However it returns 129)
>
> Here is a quick test....
> ----------------------------------------------------------
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> double test;
> test=pow(2,8)/2+1; //figure 2 to the eighth power +1
> printf("The number is %0.0f \n",test);
> system("PAUSE");
> return 0;
> }
> -----------------------------------------------------------
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> float test;
> test=((2^8+1) / 2); //figure 2 to the eighth power +1
> printf("The number is %0.0f \n",test);
> system("PAUSE");
> return 0;
> }
> -------------------------------------------------------------
>
> Here is a quick snippett from the actual source code i'm using to
> position points.
>
> sprintf( cmd, "MAKEBOX <%g %g %g> <%g %g %f> <%d %d %d>",
> -128.5, -0.0, -128.5, pow(2,8)/2+1, 0.0, pow(2,8)/2+1, 1, 1, 1 );
> local->evaluate( local->data, cmd );
>
> Both suffer from the returning the same 129 figure....
> I must be missing something stupid... (i'll try again in the morning)
>
> Thanks for the help guys..
>
> Cheers,
> Scott.
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
|
|
From: Per W. <pw...@ia...> - 2005-06-27 12:59:47
|
2 raised to 8 is 256. Dividing by two is 128. 128+1 is 129.
Your compiler don't do wrong. You have to know what _you_ want before
putting requirements on the compiler.
The easiest way to get 128.5 is:
a = 128.5.
If you want a formula to evaluate to 128.5 for a specific variable value,
you have to explain what the formula should evaluate to reach the value
128.5 (or possibly -128.5).
/Per W
On Mon, 27 Jun 2005, Scott wrote:
> >I'm not sure how abs() would help.. unless that's to ensure that the
> >original value is positive before multiplying by negative one?
> >-Lukas
>
> This is still not working right,
> Iv'e been scratching my head on this all day..
>
> I'm trying to get the value of 128.5
> But instead all the mentioned formula's are giving me 129...
>
> What i'm trying to express is this..
>
> (2^8+1)/ 2 = 128.5
>
> So in C/C++ it should be pow(2,8)/2+1 (However it returns 129)
>
> Here is a quick test....
> ----------------------------------------------------------
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> double test;
> test=pow(2,8)/2+1; //figure 2 to the eighth power +1
> printf("The number is %0.0f \n",test);
> system("PAUSE");
> return 0;
> }
> -----------------------------------------------------------
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> float test;
> test=((2^8+1) / 2); //figure 2 to the eighth power +1
> printf("The number is %0.0f \n",test);
> system("PAUSE");
> return 0;
> }
> -------------------------------------------------------------
>
> Here is a quick snippett from the actual source code i'm using to position
> points.
>
> sprintf( cmd, "MAKEBOX <%g %g %g> <%g %g %f> <%d %d %d>",
> -128.5, -0.0, -128.5, pow(2,8)/2+1, 0.0, pow(2,8)/2+1, 1, 1, 1 );
> local->evaluate( local->data, cmd );
>
> Both suffer from the returning the same 129 figure....
> I must be missing something stupid... (i'll try again in the morning)
>
> Thanks for the help guys..
>
> Cheers,
> Scott.
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: andrey <ak...@bk...> - 2005-06-27 13:53:55
|
(2^8+1)/ 2 isn't pow(2,8)/2+1
try
double test = (pow(2.0,8.0)+1.0)/2.0;
it will give you 128.5 because compiler know each value in expression DOUBLE
(sorry for my english)
Andrey
>
> >I'm not sure how abs() would help.. unless that's to ensure that the
> >original value is positive before multiplying by negative one?
> >-Lukas
>
> This is still not working right,
> Iv'e been scratching my head on this all day..
>
> I'm trying to get the value of 128.5
> But instead all the mentioned formula's are giving me 129...
>
> What i'm trying to express is this..
>
> (2^8+1)/ 2 = 128.5
>
> So in C/C++ it should be pow(2,8)/2+1 (However it returns 129)
>
> Here is a quick test....
> ----------------------------------------------------------
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> double test;
> test=pow(2,8)/2+1; //figure 2 to the eighth power +1
> printf("The number is %0.0f \n",test);
> system("PAUSE");
> return 0;
> }
> -----------------------------------------------------------
> #include <stdio.h>
> #include <math.h>
> void main()
> {
> float test;
> test=((2^8+1) / 2); //figure 2 to the eighth power +1
> printf("The number is %0.0f \n",test);
> system("PAUSE");
> return 0;
> }
> -------------------------------------------------------------
>
> Here is a quick snippett from the actual source code i'm using to position
> points.
>
> sprintf( cmd, "MAKEBOX <%g %g %g> <%g %g %f> <%d %d %d>",
> -128.5, -0.0, -128.5, pow(2,8)/2+1, 0.0, pow(2,8)/2+1, 1, 1, 1 );
> local->evaluate( local->data, cmd );
>
> Both suffer from the returning the same 129 figure....
> I must be missing something stupid... (i'll try again in the morning)
>
> Thanks for the help guys..
>
> Cheers,
> Scott.
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|