Searching \ for 'AW: AW: [PIC]:Floating point' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'AW: [PIC]:Floating point'.

Truncated match.
PICList Thread
'AW: AW: [PIC]:Floating point'
2003\05\08@100314 by eger Stefan Georg

flavicon
face
The problem I have is the following:

       float voltage;
       float voltage_HB1;
       float voltage_HB2;

       voltage = voltage_HB1 - voltage_HB2;
               
       if(voltage_HB2 > voltage_HB1)
       {
               voltagePositiv = FALSE;
       }
       else
       {
               voltagePositiv = TRUE;
       }
....voltage_HB1 and voltage_HB2 are voltages that I get from the A/D-
module. At the end I have to show the voltage on a LCD- Display. But the
display shows always the wrong value. Now, I don´t know, if the problem is
about the variable "voltage", because I don´t know what happens, if
voltage_HB2 is greater then voltage_HB1? But maybe the problem is caused by
another thing!

-----Ursprüngliche Nachricht-----
Von: Spehro Pefhany [spam_OUTspeffTakeThisOuTspamINTERLOG.COM]
Gesendet: Donnerstag, 8. Mai 2003 15:37
An: .....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU
Betreff: Re: AW: [PIC]:Floating point


At 03:21 PM 5/8/2003 +0200, you wrote:
>No, it´s not floating point it´s the easy datatype "float"....for example:
>float number = -2000;?

If you have some kind of bastardized compiler it might be better to
write:

float number = -2000.;

Also consider using "double".

Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the
reward"
speffspamKILLspaminterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\05\08@103623 by eger Stefan Georg

flavicon
face
Yes, you are right, my English is not the best...easy means simple...

-----Ursprüngliche Nachricht-----
Von: Spehro Pefhany [.....speffKILLspamspam.....INTERLOG.COM]
Gesendet: Donnerstag, 8. Mai 2003 16:29
An: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
Betreff: Re: AW: [PIC]:Floating point


At 03:46 PM 5/8/2003 +0200, you wrote:
>What is an "easy datatype"?

I have not the slightest; I didn't write that. I assume it's a translation
of "simple" from another language than English.

>What is a "bastardized compiler"?

One that does not conform substantially to the
ISO/IEC 9899:1999 (E) standard. The "." I suggested prevents conversions
from taking place, so it matters less.

>Why should it be double?

There can be unholy interactions between the linked FP libraries
and the data type selected, IME. Check carefully that everything is
consistent.

Best regards,

Spehro Pefhany --"it's the network..."            "The Journey is the
reward"
speffspamspam_OUTinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\05\08@105958 by eger Stefan Georg

flavicon
face
No, that´s not the problem.....after the A/D- conversion I make a type cast
from "integer" to "float". And if I try to show at first the value of the
variable "voltage_HB1" on the display and then the value of "voltage_HB2",
then I get the right values for both A/D- channels.
-----Ursprüngliche Nachricht-----
Von: Alan B. Pearce [@spam@A.B.PearceKILLspamspamRL.AC.UK]
Gesendet: Donnerstag, 8. Mai 2003 16:47
An: KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU
Betreff: Re: AW: [PIC]:Floating point


>....voltage_HB1 and voltage_HB2 are voltages that I get from the A/D-
>module. At the end I have to show the voltage on a LCD- Display. But the
>display shows always the wrong value. Now, I don´t know, if the problem is
>about the variable "voltage", because I don´t know what happens, if
>voltage_HB2 is greater then voltage_HB1? But maybe the problem is caused by
>another thing!

I suspect your problem is that you are using "float" to describe the value
from the ADC, when it should be "integer". If it is not properly type cast
then you will end up with funny things happening.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\05\08@111036 by Rick Regan

picon face
> No, that4s not the problem.....after the A/D-
> conversion I make a type cast
> from "integer" to "float". And if I try to show at
> first the value of the
> variable "voltage_HB1" on the display and then the
> value of "voltage_HB2",
> then I get the right values for both A/D- channels.

Since A/D results are integer, could you explain
why you need to make them 'float' to compare
and display them?


__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...