Author Topic: Change float in calculation and display  (Read 6047 times)

Offline 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Change float in calculation and display
« on: May 06, 2011, 05:36:08 pm »
Hello world,  :P

me and my friend we have the same programm but me with C::B and him with C++ builder.
In our programm we write in a txt files values (order of magnitude: 4.5675e-10 ) but when i compare my result and his results we have a difference:

==> I have 4 (or 5 i don't remember) digits
==> my friend have near 10 digits

how i can solve it? i want to increase the number of digit when i write something with the command "ofstream"
i have test ::setprecision , std::fixed/std::scientific, std::setw
but it don't work ....


during the program we have difference when there is conditions like this:
Code
if (a < 4.5675023e-10)
{
}
So, i don't know if my program round number or if it is just in displaying...? (sometime we haven't the same result with my friend, so i think my compilator is not very accurate?? it's this or a little difference in our programm?)

Can you help me by explanation of your opinion ?
thank you  :D

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Change float in calculation and display
« Reply #1 on: May 06, 2011, 05:45:29 pm »
My opinion is that your question has to do with C++ and the STL in the area of stream formatting. For that reason it has absolutely nothing to do with Code::Blocks. There is a huge difference between an IDE and a programming language + its standard library.

In short, your question does not belong here. Please search the web for an answer, or post it in appropriate website.

Offline 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Change float in calculation and display
« Reply #2 on: May 06, 2011, 06:02:34 pm »
My opinion is that your question has to do with C++ and the STL in the area of stream formatting. For that reason it has absolutely nothing to do with Code::Blocks. There is a huge difference between an IDE and a programming language + its standard library.
In short, your question does not belong here. Please search the web for an answer, or post it in appropriate website.
ok, sorry...

i have asked it because i think that in the compilator of C::B there is a limit for digits and this limit is different that C++Builder... ?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7588
    • My Best Post
Re: Change float in calculation and display
« Reply #3 on: May 06, 2011, 06:47:35 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Change float in calculation and display
« Reply #4 on: May 06, 2011, 07:27:54 pm »
Code::Blocks IS NOT a Compiler!!!
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_What_Code::Blocks_is_not.3F
Tim S.

it include a compiler...

thnak you all for your help

see you

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Change float in calculation and display
« Reply #5 on: May 06, 2011, 07:52:20 pm »
Code::Blocks IS NOT a Compiler!!!
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_What_Code::Blocks_is_not.3F
Tim S.

it include a compiler...

thnak you all for your help

see you
We include a compiler on windows (in one of th etwo install-files) for the users convenience, but we do not answer general progarmming questions in this forum/website.
It's stated clearly in the forum rules (you should have read it before posting), so your violating our forum rules !!

Offline 21did21

  • Multiple posting newcomer
  • *
  • Posts: 20
Re: Change float in calculation and display
« Reply #6 on: May 07, 2011, 06:13:07 pm »
It's stated clearly in the forum rules (you should have read it before posting), so your violating our forum rules !!

ok, sorry.