π
<-

iostream et STL

C, C++, ASM...

Re: iostream et STL

Unread postby parisse » 24 Mar 2014, 14:04

User avatar
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 89.4%
 
Posts: 3721
Joined: 13 Dec 2013, 16:35
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby Adriweb » 24 Mar 2014, 14:26

In TI-Nspire Lua, here are some tests :

Code: Select all
print( (2^52+1.)-2^52-1 )  --> 0
print( (2^53+1.)-2^53-1 )  --> -1


However I'm not sure what to test with (2^47+b)-2^47-b.
I did that, just in case :
Code: Select all
for b=2.0,11.0 do
    print( "b=" .. b, " ", "(2^53+b)-2^53-b = " .. (2^53+b)-2^53-b )
end

b=2       (2^53+b)-2^53-b = 0
b=3       (2^53+b)-2^53-b = 1
b=4       (2^53+b)-2^53-b = 0
b=5       (2^53+b)-2^53-b = -1
b=6       (2^53+b)-2^53-b = 0
b=7       (2^53+b)-2^53-b = 1
b=8       (2^53+b)-2^53-b = 0
b=9       (2^53+b)-2^53-b = -1
b=10       (2^53+b)-2^53-b = 0
b=11       (2^53+b)-2^53-b = 1



(tested with the computer software, but that part shouldn't be different... (Also, I got the same result with 2^46 on the calc application in TINCS btw.))

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 79.7%
 
Posts: 14820
Images: 1131
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: iostream et STL

Unread postby parisse » 24 Mar 2014, 15:08

b=2. gives the desired answer, lua indeed uses binary floats (with 53 bits mantissa, certainly C double type). Therefore a correct sprintf and strtod must be somewhere in the system for lua usage, but probably not where the os.h syscall points to.
User avatar
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 89.4%
 
Posts: 3721
Joined: 13 Dec 2013, 16:35
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby Legimet » 25 Mar 2014, 17:13

Vogtinator reported that he has a functioning port of Newlib, and printf is working with floats.
User avatar
LegimetProgrammeur
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 8%
 
Posts: 13
Joined: 12 Dec 2013, 02:49
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby parisse » 25 Mar 2014, 17:37

Are iostream and STL support also expected? Because if it's on the way, then I'll wait...
I could not make ustl iostream work, so I'm using nio::console. With #define and typedef, cin/cout/cerr now work on the console (extended to double and char, with minimal support for double), string and vector are working, still need to translate fstream, i/ostringstream/map not tested.
User avatar
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 89.4%
 
Posts: 3721
Joined: 13 Dec 2013, 16:35
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby Legimet » 25 Mar 2014, 17:42

Well, it should be easy to port libstdc++ once we can use newlib.
User avatar
LegimetProgrammeur
Niveau 4: MC (Membre Confirmé)
Niveau 4: MC (Membre Confirmé)
Level up: 8%
 
Posts: 13
Joined: 12 Dec 2013, 02:49
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby parisse » 26 Mar 2014, 08:31

Not that clear, since exceptions are disabled. But should be easier of course.
User avatar
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 89.4%
 
Posts: 3721
Joined: 13 Dec 2013, 16:35
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby Vogtinator » 29 Mar 2014, 19:06

So, I finally made an account here :D

In the official ndless tree on github ( http://github.com/OlivierA/Ndless ) newlib is now officially supported. You can't use it together with os.h in the same file, so non-standard syscalls like isKeyPressed are not going to work (yet).
In my ndless fork (http://github.com/Vogtinator/Ndless) I cleaned up a lot of deprecated stuff and libstdc++ is supported, but exceptions aren't easily doable without ELF as dwarf-2 exception handling depends on ELF (.ARM.exidx section) and --enable-sjlj-exceptions breaks the GCC build ("Internal error")... As it's not possible to disable RTTI in libstdc++ (but in programs built with it) even a simple "Hello World!" with iostream gets quite big (400k) but it works.
You'll have to rebuild your toolchain (gcc, newlib and elf2flt to be exact) to use the new features.
I didn't test everything yet, so there may be a lot of bugs, so if something doesn't work, please tell us.
User avatar
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)
Niveau 9: IC (Compteur Infatigable)
Level up: 1.6%
 
Posts: 217
Joined: 29 Mar 2014, 15:55
Gender: Male
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby parisse » 30 Mar 2014, 09:14

Is there some howto that describes what needs to be done? Or even better a tarball of a working toolchain?
On my side, I could compile giac with ustl (modified), nspire-io and os.h, the resulting binary is 7M large, but it does not work. I tried to set a breakpoint at the beginning of main, but reboot happens before, it happens during static initializations, despite the fact I turned on all flags to compile giac without static object initializations. And I can't find how to set a breakpoint before main.
User avatar
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 89.4%
 
Posts: 3721
Joined: 13 Dec 2013, 16:35
Gender: Not specified
Calculator(s):
MyCalcs profile

Re: iostream et STL

Unread postby parisse » 30 Mar 2014, 09:38

Link to my .ndless directory:
http://www-fourier.ujf-grenoble.fr/~parisse/calc/ndless.tar.bz2
to be unarchived in your home directory. Contains nspire and modified ustl (and also libtommath). Can be used with ustl instead of std namespace. You must define cin/cout/cerr in the code, like
for example
Code: Select all
/**
* C++ demo
*/

#define std ustl
#include <iostream>
#include < string >
#include <vector>
#include <fstream>
#include <map>
#include <cmath>
#include <complex>
#include <algorithm>
#include <functional>
#include <cerrno>
#include <stdexcept>
#include <limits>
using namespace std;
const char std::endl='\n';
nio::console * std::console_cin_ptr=0;
#define cin (*console_cin_ptr)
#define cout (*console_cin_ptr)

int main(void)
{
  nio::console console_cin;
  console_cin_ptr=&console_cin;
  clrscr();
  std::string s ="coucou";
  s += " abc ";
  cout << 12.3 << bidon.x << " ab " << s<< endl;
  cin >> s;
  s = s+ " entered";
  cout << s << endl;
  vector<int> v; int i;
  for (int j=1;j<3;j++){
    cin >> i;
    v.push_back(i);
  }
  sort(v.begin(),v.end());
  for (unsigned i=0;i<v.size();++i)
    cout << v[i] << ' ';
  map<int,int> m;
  m[1]=2;
  //double c=3.;
  complex<double> c(1,2);
  cout << pow(c,3.) << endl;
  wait_key_pressed();
  return 0;
}


(from
http://www-fourier.ujf-grenoble.fr/~parisse/calc/nspire-io.tar.bz2,
http://www-fourier.ujf-grenoble.fr/~parisse/calc/ustl-2.1.tar.bz2)
The modified giac code that compiles with ustl/nspireio is here
http://www-fourier.ujf-grenoble.fr/~parisse/calc/giac.tgz
the binary giac.tns and debugging symbols are in the giac/src directory.
User avatar
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)
Niveau 12: CP (Calculatrice sur Pattes)
Level up: 89.4%
 
Posts: 3721
Joined: 13 Dec 2013, 16:35
Gender: Not specified
Calculator(s):
MyCalcs profile

PreviousNext

Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: ClaudeBot [spider] and 1 guest

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
1234
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
608 utilisateurs:
>595 invités
>6 membres
>7 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)