h4kuna / data-type

Basic data type
7 stars 1 forks source link

Float fromString Error is strring before or at the end #6

Closed ickbinhier closed 6 years ago

ickbinhier commented 6 years ago

Hello,

I have a problem.

Float :: fromString ('1,40 €'); and Float :: fromString ('$ 1.40'); make a mistake.

I have created a Pull Request. Can You please check this.

https://github.com/h4kuna/data-type/pull/5

h4kuna commented 6 years ago

Hi, this not use case for Float::fromString(). You must write own parser. If you remove currency symbol, then you use Float::fromString()

ickbinhier commented 6 years ago

I understand that.

But so far I've thought that the purpose of this class is to take a string and extract the float from it, no matter what the user types.The € and $ were just examples.

Have I been wrong and you see another sense in the class?

Am 22.04.2018 um 20:45 schrieb Milan Matějček:

Hi, this not use case for |Float::fromString()|. You must write own parser. If you remove currency symbol, then you use |Float::fromString()|

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4kuna/data-type/issues/6#issuecomment-383403267, or mute the thread https://github.com/notifications/unsubscribe-auth/ACrkGFTjsdqHOHN-3PPR60n5fOPmcITNks5trM_mgaJpZM4TeUfI.

-- Andreas Lemke Anwendungsentwickler, Administrator und IT-Koordinator

eMail: andreas.lemke@tu-braunschweig.de Tel: +49 531 391-7296 Fax: +49 531 391-8228

Anschrift: TU Braunschweig Sprachenzentrum Bültenweg 74 38106 Braunschweig

h4kuna commented 6 years ago

Hi, it is only reverse function for number_format

ickbinhier commented 6 years ago

And that is different with the Ints class?

https://github.com/h4kuna/data-type/blob/4db7e6d4a5201940b3d24b7743bf6ed3e00b581e/src/Basic/Ints.php#L29

Am 23.04.2018 um 11:35 schrieb Milan Matějček:

Hi, it is only reverse function for number_format http://php.net/manual/en/function.number-format.php

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/h4kuna/data-type/issues/6#issuecomment-383514738, or mute the thread https://github.com/notifications/unsubscribe-auth/ACrkGIrb8IbN-qnE3rfpRsB7oFvX1A0Jks5traBJgaJpZM4TeUfI.

-- Andreas Lemke Anwendungsentwickler, Administrator und IT-Koordinator

eMail: andreas.lemke@tu-braunschweig.de Tel: +49 531 391-7296 Fax: +49 531 391-8228

Anschrift: TU Braunschweig Sprachenzentrum Bültenweg 74 38106 Braunschweig

h4kuna commented 6 years ago

Find int is easier then float where is delimiter like comma or dot.

h4kuna commented 6 years ago

Int::fromString is little bit dangerous becasue

Foo 64, bar 63
// result is int 6463