Extension talk:NumberFormat

About this board

extension does not work

1
Nicole Sharp (talkcontribs)

Unfortunately, this extension does not work.

{{#number_format:2.7182818284590452353602874713526624977572470936999595749669676|_}}

displays as

2.7182818284590450907955982984276488423347473144531250000000000

instead of

2.7182818284590452353602874713526624977572470936999595749669676

Nicole Sharp (talk) 20:09, 29 March 2021 (UTC)

Reply to "extension does not work"

Is there a way to make this work on 1.32?

5
Extarys (talkcontribs)

Or is there any alternative to format numbers? Thanks! <3

Kghbln (talkcontribs)

What's wrong on 1.32?

Extarys (talkcontribs)

It complains there is no extension.json or something... I'm sorry I should have been more precise.

Kghbln (talkcontribs)

This is expected. Did you follow the installation instructions?

Extarys (talkcontribs)

Oh Silly me, I was convinced that the old way of importing extensions was deprecated... Thanks, adding the require_once worked. Sorry and thanks for your time!

Reply to "Is there a way to make this work on 1.32?"

Fatal error: Cannot redeclare number_format_Setup()

1
Summary by Kghbln

Admin error. Please ignore.

Kghbln (talkcontribs)

Reported with task T219061. Probably an issue with PHP 7.2.x!?

Question about thousands separator

2
Uncopy (talkcontribs)

Our wiki needs to get for example 1234.50 from 1234.501 (IOW: no thousands separator and 2 decimal places) but the round function of PHP doesn't keep dangling zeros and therefore the same is true for the round available in #expr. Would we get the requested result by {{#number_format:1234.501|2|.|}}?

Maybe this question seem redundant, but the combination of empty thousands_sep and dangeling zeros is crucial for us and the French example combines a lot of features which (sort of) confuses me. Thanks for your help :)
--Uncopy (talk) 21:17, 26 October 2018 (UTC)

BTW: the example link is broken. Hopefully, the next will be somewhere on https://xen.wiki --Uncopy (talk) 21:37, 26 October 2018 (UTC)
Pastakhov (talkcontribs)

Hi,

{{#number_format:1234.501|2|.|}}

returns 1234.50

Reply to "Question about thousands separator"

PHP Warning: number_format()

2
Summary by Kghbln

Fix served with 0.8.2!

Kghbln (talkcontribs)
Setup
  • MediaWiki 1.29.0-rc.1 (929f8dc) 01:59, 8 July 2017
  • PHP 5.6.30-0+deb8u1 (apache2handler)
  • MariaDB 10.0.31-MariaDB-1~jessie
  • NumberFormat 0.8.1 (e879011) 14:15, 15 August 2015
Issue

PHP Warning: number_format() expects parameter 2 to be long, string given in /../w/extensions/NumberFormat/NumberFormat.php on line 81

@Pastakhov: I cannot tell exactly if this started out after the upgrade to 1.29 or if this was already present before. I found this in the servers error log.

Pastakhov (talkcontribs)
Summary by Pastakhov

until version 0.8.0 this extension didn't work with negative numbers

AdSvS (talkcontribs)

Hi, it seems that this extension doesn't work with negative numbers. Is that correct? I thought it would be a good alternative for formatnum, because formatnum gives errors with php 5 and this one doesn't. But I didn't think it would ignore negative numbers. Is this a bug?

Pastakhov (talkcontribs)

Hi! Yes, it is a bug. I'll fix it, thanks for report.

Pastakhov (talkcontribs)

The bug has been fixed in version 0.8.0

Kghbln (talkcontribs)

That's absolutely great. Thank you for your effort and work. This is much appreciated!

AdSvS (talkcontribs)

Indeed it is! Thanks Pavel! Sorry that my php-knowledge is non-existent...

Kghbln (talkcontribs)
Pastakhov (talkcontribs)

Done

Stefahn (talkcontribs)

Hello Patrick & Pavel,

I just wanted to say "Thanks a lot" for this great extension!

On my site I show prices with help of SMW. The problem was that prices like 27,10 € were shown as 27,1 € and not as 27,10 €. First I played around with {{padright:{{#ifeq:{{#len:foo}}|2|foo,|foo}}|5|0}} (which worked), but then I found your extension which is much more convenient.

Just a hint for German users: If you have a number like 27,1 and want to convert it to 27,10 use the following code:

{{#number_format:your_number|2|,|.|,}}

Thanks again!

Pastakhov (talkcontribs)

Thanks for the feedback! I am glad that this extension helps you :-)

Reply to "Great extension!"
205.209.247.222 (talkcontribs)

I love the idea of your extension. I am currently working on a pet project to build a complete, semantic CMDB so I need to be able to get rid of the comma in Office 2010 (just for example).

Do you know how I could use this function for inline quieries and the like? Most everything I'm doing is storing each piece of information and it's properties (software title, product key, vendor, version, etc) as one 'page' and calling queries throughout the rest of the site to aggregate all of that data together, using the semantic properties to pull exactly what we need every time.

Any help would be greatly appreciated!

Pastakhov (talkcontribs)

Hi, I'm not quite sure what the problem is.

I use this extension to clean the user input: [[MyNumberProperty::{{#number_format:{{{Value|0}}}|_|.||,}}]]

And clear the result of the query:

{{#ask: ...
|?MyNumberProperty
| mainlabel=-
| format=array
| name=myArray
}}

{{#arrayprint:myArray |<br /> |@@@@|{{#number_format:{{#explode:@@@@|<PROP>|0}}|_|.||,}} }}

There may be bugs, so it is not a real-life example.

For simplicity, I use a template Num: {{#iferror: {{#if: {{{1|}}} | {{#number_format:{{{1|0}}}|_|.||,}} | 0 }} | 0 }}

Then, {{#arrayprint:myArray |<br /> |@@@@|{{Num|{{#explode:@@@@|<PROP>|0}}}} }}

Cjg1979 (talkcontribs)

The problem is quite obviously me.  :)

In all seriousness, I'm just getting my feet wet with MediaWiki. I tried out DokuWiki but it was so limited, so I'm coming into MediaWiki with bad forms already in my head, and I've only been at it a week or two. That's why I asked how one would accomplish it, not if it could.

And thank you for the awesome example. You have given me more fodder for learning in this one message than I have seen all week. I'm loving all that SMW will do, and I'm trying to learn it as fast as I can. But it seems like I'm coming in late in the game!

I'll try your example out tomorrow and see if I can figure out the syntax.

Thanks again!

Reply to "Inlilne Queries"
There are no older topics
Return to "NumberFormat" page.