I am aware that the language has support for dealing with the OS's real floating-point numbers, according to the tice.h include file. I have a few questions on how I may work with it.

1. How do I initialize a real_t type to a number, such as 4, 7.93, or 2.7E19?
2. How do I do arithmetic to a real_t type?
3. Is there a way to get a string usable in C with the string representation of a real_t type in it?
JWinslow23 wrote:
I am aware that the language has support for dealing with the OS's real floating-point numbers, according to the tice.h include file. I have a few questions on how I may work with it.

1. How do I initialize a real_t type to a number, such as 4, 7.93, or 2.7E19?
2. How do I do arithmetic to a real_t type?
3. Is there a way to get a string usable in C with the string representation of a real_t type in it?


1. These functions (Note that TI reals technically have more precision than C floats, so you may need to do some rounding)

int24_t os_RealToInt24(const real_t *arg);
real_t os_Int24ToReal(int24_t arg);
float os_RealToFloat(const real_t *arg);
real_t os_FloatToReal(float arg);

2. You can either use one of the above functions to convert a real type to a C type, or simply use the functions in tice.h such as os_RealAdd, os_RealDiv, os_RealGcd, etc.

3. Yes, check out the os_RealToStr routine documented in tice.h

In addition, the fileio library provides additional support and examples using these functions (Look at fileio examples 3 and 4)
MateoConLechuga wrote:
JWinslow23 wrote:
I am aware that the language has support for dealing with the OS's real floating-point numbers, according to the tice.h include file. I have a few questions on how I may work with it.

1. How do I initialize a real_t type to a number, such as 4, 7.93, or 2.7E19?
2. How do I do arithmetic to a real_t type?
3. Is there a way to get a string usable in C with the string representation of a real_t type in it?


1. These functions (Note that TI reals technically have more precision than C floats, so you may need to do some rounding)

int24_t os_RealToInt24(const real_t *arg);
real_t os_Int24ToReal(int24_t arg);
float os_RealToFloat(const real_t *arg);
real_t os_FloatToReal(float arg);

2. You can either use one of the above functions to convert a real type to a C type, or simply use the functions in tice.h such as os_RealAdd, os_RealDiv, os_RealGcd, etc.

3. Yes, check out the os_RealToStr routine documented in tice.h

In addition, the fileio library provides additional support and examples using these functions (Look at fileio examples 3 and 4)

I cannot thank you enough! Wink
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement