Boa: Implement optional parameter `radix` for `Number.prototype.toString( [radix] )`

Created on 5 May 2020  路  9Comments  路  Source: boa-dev/boa

Currently we only support toString function with radix/base 10.
The radix can be from 2 to 36.

More information:

enhancement good first issue

Most helpful comment

I can take look at this

All 9 comments

I can take look at this

I cannot any way to throw an exception. Is it possible spec requires you to RangeError exception if radix is less than 2 or greater than 36

also does this method needs to be comprehensive as the spec if not how comprehensive should it bee

I cannot any way to throw an exception. Is it possible spec requires you to RangeError exception if radix is less than 2 or greater than 36

Currently, we don't have exception management yet. The current approach is to just panic!(), but put a comment to make sure we go back to it once exceptions get implemented :)

About comprehensiveness, it should be comprehensive, yes. If you find a way of optimizing something without making things too complex, do it, though. We can review it further once you have the first prototype :)

https://github.com/jasonwilliams/boa/pull/381 i created a draft pr (it is highly WIP) the problem is i cant wrap my head around converting floating point part of a number to a different base. Any idead on how to do it ?. The main part that i dont understand is i know that main way to calculate a fraction in base N is multiply it with N take the non fraction part and continue but what is the stop condition and how to handle repeating fractions ?

Also another thing i noticed is we need a test suite that allow us to write tests in pure js like in the V8. It would also allow us to add new tests and running them without having to recompile the whole test suite.

381 i created a draft pr (it is highly WIP) the problem is i cant wrap my head around converting floating point part of a number to a different base. Any idead on how to do it ?. The main part that i dont understand is i know that main way to calculate a fraction in base N is multiply it with N take the non fraction part and continue but what is the stop condition and how to handle repeating fractions ?

Hmmm I don't have experience with this. The spec shows a potential algorithm, but I'm not sure how we should do it. How does V8 do it? Maybe @jasonwilliams or @HalidOdat have some ideas.

Also another thing i noticed is we need a test suite that allow us to write tests in pure js like in the V8. It would also allow us to add new tests and running them without having to recompile the whole test suite.

About this, our idea is to setup test262 harness at some point (#12). This would run to check how much we are implementing from the spec. We also have the option of doing cargo run -- test_file.js, that is useful for testing. The good thing about using Rust tests is that they are very easy to setup.

In the long run we might be able to setup a better testing infrastructure.

Initial definition is here. I have no idea on what a tq file is. And the the actual implementation is here. Damn it is really hard to find something in the v8 source code.

I have no idea on what a tq file is.

They are V8 torque language files: V8 Torque

And the the actual implementation is here.

It shouldn't be too hard to translate the C++ code to Rust.

Damn it is really hard to find something in the v8 source code.

I know, right! Sometimes it gets so convoluted! And It does not help that some places have no documentation!

I am converting the c++ code to rust. I first converted it into c by hand than i used c2rust to convert into rust. Now i am prettifying the generated rust code.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonwilliams picture jasonwilliams  路  6Comments

HalidOdat picture HalidOdat  路  3Comments

jasonwilliams picture jasonwilliams  路  4Comments

Razican picture Razican  路  5Comments

croraf picture croraf  路  5Comments