LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 02-19-2002, 09:53 AM   #1
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Rep: Reputation: 30
Scientific notation for C


I am reading a C book and it is talking about scientific notation... it refers to the number: 5e7 for example and mentions this format [mantissa]e[exponent]... and little else...

I get the framework idea but what "real" number would this 5e7 actually be? I know its not Linux-specific but i figured id run it by you guys since you seem to know darn near everything ...

thanks
 
Old 02-19-2002, 09:59 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
5e7 = 5 x 10^7 = 50,000,000
 
Old 02-19-2002, 10:08 AM   #3
Malicious
Member
 
Registered: Jan 2002
Location: Galveston Island
Distribution: suse, redhat
Posts: 208

Rep: Reputation: 30
The printf and scanf functions handle scientific notation for input and output. In the program you would use float (32bit) or double (64bit) data types. This notation is a short way to write very large or very small numbers. In effect, take the first number, put a decimal point behind it (5.0) and then move the decimal point to the right using the second number to count the places (50000000.0). If the second number is negative (5e-7), move the decimal place to the left (0.0000005). I think that's the way it works.
 
Old 02-19-2002, 10:21 AM   #4
Chijtska
Member
 
Registered: Jan 2002
Location: High Falls, GA
Distribution: Mandrake8.2, FreeBSD, Solaris
Posts: 362

Original Poster
Rep: Reputation: 30
ok that makes perfect sense... (i should have been able to guess at that on my own). now lets say we flip flopped the concept and wanted to write a scientific notation number for say 5335... how would that be written?
 
Old 02-19-2002, 10:24 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,415

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
5.335e3

oh come on, you can work this out for yourself. this is nothing to do with linux. go read a maths textbook.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to use bc to handle numbers in scientific/exponential notation? zero79 Linux - General 3 09-14-2008 11:36 PM
pointer notation vs array notation? pablowablo Programming 5 03-14-2005 01:34 PM
The Scientific Miracles rinard General 18 03-23-2004 01:08 AM
Scientific Software linux_fresher Linux - Software 3 08-18-2003 08:46 AM
scientific calculator mtint Linux - Software 0 10-20-2002 07:05 PM


All times are GMT -5. The time now is 11:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration