TI-89 HomeGames ArchiveTitanium GamesGames How ToProgramsFAQForumTI-89 WikiLinks

Displaying correct output of an Engineering program

 
Post new topic   Reply to topic    Your TI-89 Resource Forum Index -> BASIC Programming
Author Message
danp



Joined: 04 May 2007
Posts: 2
Location: UK

PostPosted: May 29, 2007 6:44 AM    Post subject: Displaying correct output of an Engineering program Reply with quote

I have some TI-Basic programming question I wonder whether you could help me with.

The basic program I am trying to write converts dBm into Watts using the following formula:-

(10^(dbm/10))/1000

dbm2watt()
Prgm
Dialog
Title"DBM to Watts"
Request "Enter DBM Value",n
EndDlog
expr(n)->n

(10^(n/10))/1000)->n

disp n

dialog
"Watts ="
text string(n)&" Watts"
endDlog

EndPrgm



(1) if you type in 53 for instance (which is 199.5 watts) the result of disp n doesn't give a numeric answer but just the formula 100*10^(3/10) which is the calculator displaying the simplidfied version of the formula.
The second dialog bos is just intended to display the result in a pretty box.

If i press the diamond button before entering dbm2watt() i get the numerical answer.

How do you force the program to give a numeric answer and not just the formula display without having to press the diamond button before executing the program?

I have prettyprint turned off by the way.

Sorry for the long question i hope u can help.

Cheers

Back to top
View user's profile Send private message
mellamokb



Joined: 10 May 2007
Posts: 124

PostPosted: May 29, 2007 12:00 PM    Post subject: Reply with quote

Hi danp,

Try the "approx(" function to force a decimal answer. You can also put your calculator into "approx" mode or "auto" mode. Note that in "auto" mode you can get a decimal result just by entering a decimal "." as some part of the expression (for instance, include a "1." instead of just "1").

For such a simple conversion, it would be much easier to use a function instead of a program. You can just define a function that does the calculation, and then you can use it like other built-in functions. Try this on the homescreen:

Code:

Define dbm2watt(n)=approx(10^(n/10))/1000)



A lot less overhead, less memory, and easier to use! To use this, simply type "dbm2watt(53)" on the homescreen (or any other number).

Hope this helps!

~ mellamokb
Back to top
View user's profile Send private message
Display posts from previous:    View previous topic : View next topic  
Post new topic   Reply to topic    Your TI-89 Resource Forum Index -> BASIC Programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Contact Us | Privacy Policy | Disclaimer | Trademarks

Copyright ©2006 All rights reserved.


Free Greeting Cards | Girly Myspace Layouts | Myspace Unblocker |