Jump to content



Photo
- - - - -

Display Decimals


  • Please log in to reply
3 replies to this topic

#1 Fez

Fez

    Casio Freak

  • Members
  • PipPipPipPip
  • 162 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio fx-9860G AU

Posted 14 May 2008 - 09:32 AM

So, Im making a calc Add In using the SDK.

I'm wondering, How would I display decimals. I know its f, or a g. But I cant seem to get it to work.

Could you guys please give me an example of using sprintf to stick a floating point number into a string. Also how to make it rounded to 2 decimal places.

Thank You.

#2 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 14 May 2008 - 01:23 PM

Hey, here's an example:

float test = 3.14159;
char buffer[20];

Bdisp_AllClr_VRAM();
sprintf(buffer, "%0.2f", test);
PrintMini(1, 1, (unsigned char *)buffer, MINI_OVER);
Bdisp_PutDisp_DD();

You also need to make sure that stdio.h is included:
#include "stdio.h"


#3 Fez

Fez

    Casio Freak

  • Members
  • PipPipPipPip
  • 162 posts
  • Gender:Male
  • Location:Australia

  • Calculators:
    Casio fx-9860G AU

Posted 14 May 2008 - 01:39 PM

OMG thanx XD

So thats what was going wrong.
I wasnt including the file :P

It works now, so thanx alot. Also thanx for showing me the way to round them XD

#4 kucalc

kucalc

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1422 posts
  • Gender:Male
  • Location:USA
  • Interests:Programming: C/C++, Fortran, LISP, COBOL 85 Standard, PHP, x86 and SH3 Assembly

    Computer graphics

  • Calculators:
    fx-9860G / fx-7400G Plus / Algebra FX 2.0+ / fx-9770G / CFX-9850G / CFX-9850GB+ / TI-89 / TI-nSpire

Posted 14 May 2008 - 05:11 PM

Heh, no problem. :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users