iostream et STL
Re: iostream et STL
http://www-fourier.ujf-grenoble.fr/~parisse/calc/nspire-io.tar.bz2 updated with minimal support for double.
-
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 3721
- Joined: 13 Dec 2013, 16:35
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
In TI-Nspire Lua, here are some tests :
However I'm not sure what to test with
I did that, just in case :
(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.))
- 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
-
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)- Posts: 14820
- Images: 1131
- Joined: 01 Jun 2007, 00:00
- Location: France
- Gender:
- Calculator(s):→ MyCalcs profile
- Twitter: adriweb
- GitHub: adriweb
Re: iostream et STL
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.
-
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 3721
- Joined: 13 Dec 2013, 16:35
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
Vogtinator reported that he has a functioning port of Newlib, and printf is working with floats.
-
LegimetProgrammeur
Niveau 4: MC (Membre Confirmé)- Posts: 13
- Joined: 12 Dec 2013, 02:49
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
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.
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.
-
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 3721
- Joined: 13 Dec 2013, 16:35
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
Well, it should be easy to port libstdc++ once we can use newlib.
-
LegimetProgrammeur
Niveau 4: MC (Membre Confirmé)- Posts: 13
- Joined: 12 Dec 2013, 02:49
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
Not that clear, since exceptions are disabled. But should be easier of course.
-
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 3721
- Joined: 13 Dec 2013, 16:35
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
So, I finally made an account here 
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.

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.
-
VogtinatorPremium
Niveau 9: IC (Compteur Infatigable)- Posts: 217
- Joined: 29 Mar 2014, 15:55
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
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.
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.
-
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 3721
- Joined: 13 Dec 2013, 16:35
- Gender:
- Calculator(s):→ MyCalcs profile
Re: iostream et STL
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
(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.
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.
-
parisseVIP++
Niveau 12: CP (Calculatrice sur Pattes)- Posts: 3721
- Joined: 13 Dec 2013, 16:35
- Gender:
- Calculator(s):→ MyCalcs profile
Return to Native: Ndless, Linux, ...
Who is online
Users browsing this forum: ClaudeBot [spider] and 1 guest