---
title: "Avrunda till *.0, *.5 och heltal"
type: "forum-thread"
url: "https://www.webforum.nu/amne/php/93954-avrunda-till-0-5-och-heltal"
topic: "PHP"
topic_url: "https://www.webforum.nu/amne/php"
author: "filipbh"
published: "2004-01-04T18:47:31.000Z"
updated: "2004-01-04T20:48:45.000Z"
replies: 4
views: 392
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/php/93954-avrunda-till-0-5-och-heltal"
---

# Avrunda till *.0, *.5 och heltal

## #1 — filipbh, 2004-01-04T18:47Z

Hej

Skulle vilja att t.ex. 1.40 avrundades till 1.50 och 1.75 avrundas till 2. Dvs som man gör i verkligheten; 0.0-0.24 = 0, 0.25-0.74 = 0.5 och 0.75-0.99 = 1.

Nån som kan hjälpa mig??

Permalänk: https://www.webforum.nu/p/93954

## #2 — Don Tomas, 2004-01-04T19:17Z

Har du provat
round(talet,2);
?

/TN

Permalänk: https://www.webforum.nu/p/1243767

## #3 — Matte, 2004-01-04T19:31Z

Dubblera -\> Avrunda till heltal -\> Halvera

```php
$rounded_value = round(2 * $value) / 2;
```

Permalänk: https://www.webforum.nu/p/1243770

## #4 — filipbh, 2004-01-04T20:46Z

Don Tomas: Ja det har jag.. 

Matte: Ska testa det...

Permalänk: https://www.webforum.nu/p/1243816

## #5 — filipbh, 2004-01-04T20:48Z

Tack Matte, det fungerade perfekt...

mahedel (brorsan) hälsar...

Permalänk: https://www.webforum.nu/p/1243818

---

Tråden på webben: https://www.webforum.nu/amne/php/93954-avrunda-till-0-5-och-heltal
